D'oh - my own fault really. It is sooo simple when you take a little break and start again!
For others in the same situation, I borrowed the code from a post in the archive and adjusted it to suit my circumstances.
In case it proves useful, the code I used is:
$size = count($pricelist);
for ($i = 1; $i < $size; $i++)
{
for ($j = $size - 1; $j >= $i; $j--)
{
$curr = substr($pricelist[$j], 0, strpos($pricelist[$j], '#')-1);
$prev = substr($pricelist[$j-1], 0, strpos($pricelist[$j-1], '#')-1);
if ($prev > $curr)
{
$temp = $pricelist[$j-1];
$pricelist[$j-1] = $pricelist[$j];
$pricelist[$j] = $temp;
}
}
}
Richard wrote:
I have an array of strings that I need to sort (ascending) but each string starts with a number (actually a price if that helps) like this:
4.99#something#somethingelse#etc
5.99#something#somethingelse#etc
2.50#something#somethingelse#etc
12.99#something#somethingelse#etc
4.59#something#somethingelse#etc
7.25#something#somethingelse#etc
If I use "sort($arrayname)" it sorts alphanumerically like this:
12.99#something#somethingelse#etc
2.50#something#somethingelse#etc
4.59#something#somethingelse#etc
4.99#something#somethingelse#etc
5.99#something#somethingelse#etc
7.25#something#somethingelse#etc
Just thought i would ask if there is an array function or something to use so the numbers are in ascending numerical order like this:
2.50#something#somethingelse#etc
4.59#something#somethingelse#etc
4.99#something#somethingelse#etc
5.99#something#somethingelse#etc
7.25#something#somethingelse#etc
12.99#something#somethingelse#etc
All suggestions gratefully re....