Most languages have built in sorting, which works well in the majority of cases - you should use these. If keeping the information in a sorted order is important you may want to consider using a data structure other than an array.
Anyhow, here's a couple of snippets that find the lowest number in an array.
Here's a perl version:
Code:
my @unsorted = (34, 69, 12, 67, 21, 9, 78, 478327);
my @sorted = sort {$a <=> $b} @unsorted;
print "$sorted[0]\n";
Here's a ruby version:
Code:
arr=[34, 69, 12, 67, 21, 9, 78, 478327]
p arr.sort.first
Cheers
--
Don't Stand on your head - you'll get footprints in your hair
http://charlieharvey.org.uk
http://charlieharvey.com