Ezilon.com - Target Your Audience, be Seen in Your Region

Listing items...

You are viewing this site as a guest. Join our community to get your questions answered and share knowledge. Active members may advertise and ask for a website critique.

They have: 117 posts

Joined: Mar 2000

How would I list a series of items in order from greatest to least? For example:

Item A - 462
Item B - 903
Item C - 824

The script would print those items like this:
1. Item B
2. Item C
3. Item A

Also, how could I make a list of items according to the date, starting with the newest and ending with the oldest?

Thanks!!

--Edge

They have: 13 posts

Joined: May 1999

You could do that by first sorting the array.
Get the last value of the array by using $i = $#array.
Next use a loop to print out each item starting with the last, decrementing $i each time you do it. Oh hell, like this, haha :

@array = ("223", "479", "145", "906", 400");
@array = sort(@array);
$i = $#array; #gets the last item number in the array
$z = 0; #first item in the array
while ($i >= $z) {
print "$array[$i]\n";
$i--;
}

finit
should do the trick for ya.

They have: 13 posts

Joined: May 1999

As for the date thing, try using numbers for your dates :

"yymmdd" format will organize your dates by newest to oldest.

Cheers!

They have: 850 posts

Joined: Jul 1999

@array = ("462","903","824");
print(reverse(sort @array));

'
outputs
903824462

As for the date, you could use the localtime() feature, which outputs the date in a 9-number variable. Then you could just sort() the array of dates to display least to greatest.

They have: 13 posts

Joined: May 1999

Cool Smiling