Hi,
Any way to sort an array without putting DJ above Dead etc. Doble caps seem to always go to the top of the list.
Looked in manual but didn't spot anything, i could have missed it though.
Thanks
Case Insensitive sort
Moderator: General Moderators
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- johnperkins21
- Forum Contributor
- Posts: 140
- Joined: Mon Oct 27, 2003 4:57 pm
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
SORT_NUMERIC is no good because I need my list returned alphabetically.
strtolower looks good though. The only problem is that I need the results of the sort echoed back onto the page in their original format.
It's filenames in a big list so I want to display only the original way they are written even if the sort function sorts them as if they are lower case.
I'm sure that can't be too difficult to do though.
Thanks mate!
strtolower looks good though. The only problem is that I need the results of the sort echoed back onto the page in their original format.
It's filenames in a big list so I want to display only the original way they are written even if the sort function sorts them as if they are lower case.
I'm sure that can't be too difficult to do though.
Thanks mate!
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
Nice thanks!
I did it like this ($file is each file in a directory)
Or something to that effect. I didn't copy and paste it so if there are errors in that code above there's no need to tell me.
I did it like this ($file is each file in a directory)
Code: Select all
$tonefile = substr($file, 0, -4);
$lowercase = strtolower($file);
$ToneArray[$tonefile] = $lowercase;
asort($ToneArray);
foreach ($ToneArray as $n => $v) {
echo ' '.$n.' <br>';
}or just:
Code: Select all
usort($ToneArray, create_function( '$a,$b', 'return strcasecmp($a,$b);' ) )