Page 1 of 1

least number in array

Posted: Sun Feb 19, 2006 4:18 pm
by sleepwalker0
Hi this seems like a really nice community so I want to say hello :D

As you probably noticed I'm new to php and just learning.

Heres my qestion, how can I represent numbers in array like the least number or the greatest or the second least and so on. I need to sort some numbers from least to greatest but I can't use "sort()" Any suggestions.

Sleepwalker

Posted: Sun Feb 19, 2006 4:19 pm
by jwalsh
Why can't you use sort() ?

Posted: Mon Feb 20, 2006 12:27 am
by sleepwalker0
:? theres a good reason, its one of a tasks I have to complete long story..I have a good reason, anybody has any thoughts on programming side?

Posted: Mon Feb 20, 2006 12:33 am
by feyd
programming your own sort()? search around for bubble-sort algorithms. (hint: Wikipedia)

Posted: Mon Feb 20, 2006 2:19 am
by duk
theres a idea...

create a temporary table, then insert every value, into... then select all numbers and orber by ASC or DESC, and use-it for what you need, then just delete the table...

is what come to my mind first :D