Sorting an Array

hi there,

im going to loop through 17thousand mysql entries (each entry has
aunique, and incremental, id) then calculate a rating of each entry
based on some other information. (between 1 and 5)

i then want to sort the data with the highest rated entries at the top
of the list?


my first plan was to add each calculation into an array, as the array
number would match the unique id, then at the end use the sort
function, but then i would lose the unique id information by doing
this.

is there some way to use sort on an array of array[id][rating]? or an
array of objects somehow?


thanks for any help,
duncan
dunctait [ Mi, 16 Januar 2008 17:48 ] [ ID #1909732 ]

Re: Sorting an Array

On Jan 16, 11:48 am, dunctait <dunct... [at] hotmail.com> wrote:
> hi there,
>
> im going to loop through 17thousand mysql entries (each entry has
> aunique, and incremental, id) then calculate a rating of each entry
> based on some other information. (between 1 and 5)
>
> i then want to sort the data with the highest rated entries at the top
> of the list?
>
> my first plan was to add each calculation into an array, as the array
> number would match the unique id, then at the end use the sort
> function, but then i would lose the unique id information by doing
> this.
>
> is there some way to use sort on an array of array[id][rating]? or an
> array of objects somehow?
>
> thanks for any help,
> duncan

How about asort() ?

<http://us.php.net/asort>
zeldorblat [ Mi, 16 Januar 2008 17:56 ] [ ID #1909734 ]

Re: Sorting an Array

>
> How about asort() ?
>
> <http://us.php.net/asort>

that would appear to be perfect, thanks very much
dunctait [ Mi, 16 Januar 2008 18:01 ] [ ID #1909736 ]
PHP » comp.lang.php » Sorting an Array

Vorheriges Thema: Please help a newbie - PHP is running, but code is not executed
Nächstes Thema: Download xml file