www.webdeveloper.com
Results 1 to 3 of 3

Thread: sort array numerically

  1. #1
    Join Date
    Mar 2009
    Posts
    452

    sort array numerically

    hi folks, i am using glob("Data/small/*.jpg") to get a list of images in a folder and store in an array. it gives me a list as follows:

    Data/small/02.jpg
    Data/small/03.jpg
    Data/small/04.jpg
    Data/small/05.jpg
    Data/small/06.jpg
    Data/small/07.jpg
    Data/small/08.jpg
    Data/small/09.jpg
    Data/small/1.jpg
    Data/small/10.jpg
    Data/small/11.jpg
    Data/small/12.jpg

    what i want is to sort the array numerically i.e. 1.jpg should come on top. i have trid sort() as well as asort() functions with different flags but no encouraging results

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    18,923
    Try the natsort() function.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Mar 2009
    Posts
    452
    thanx alot. i will try it....

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles