Re: sorting an array.. need help
- From: "Sune Storgaard" <nospam@xxxxxxxxxxxxx>
- Date: Mon, 30 Jan 2006 17:50:04 +0100
namemattersnot@xxxxxxx wrote:
> i've have the following array:
>
> files['name'][1]
> ['size'][1]
> ['time'][1]
> files['name'][2]
> ['size'][2]
> ['mtime'][2]
> ..etc.
>
> how do I sort this array according to "time" index? so that, for
> example, files['name'][0] would give "my_file.txt" that was last
> created?
A little *dirty* trick is to rearrange the array into a new array, where the
time is first entry.
In this case, swap it around so you get
files
['time'][1]
['size'][1]
['name'][1]
When you sort it now, it will be correct as its sorted on first entry =
time.
Then swap it back to the original structure.
See the "smith / johnson/ berger" example at php.net/sort
.
- References:
- sorting an array.. need help
- From: namemattersnot
- sorting an array.. need help
- Prev by Date: Re: Newbie needs a workaround - No Cron Jobs on Godaddy shared server!
- Next by Date: Re: Newbie needs a workaround - No Cron Jobs on Godaddy shared server!
- Previous by thread: Re: sorting an array.. need help
- Next by thread: sorting an array.. need help
- Index(es):
Relevant Pages
|