I have an array of filenames that I aquire using DirectoryIterator. I am trying to get the filenames to sort so they would be in order like so, this is the way they appear on the server.
2DAYSALEGATE_PG1.jpg 2DAYSALEGATE_PG2.jpg 722_PG1.jpg PW_PG2_COKE_A.jpg PW_PG3_COKE_A.jpg PWBY4_DELI-1.jpg
When aquiring the file names they are coming out like this. I have tried to use a sort, natsort and natcasesort. The filename the underscore character is considered after the letters. What can I do to get the underscore to sorted as a priority character.
array(6) {
[0]=>
string(20) "2DAYSALEGATE_PG1.jpg"
[1]=>
string(20) "2DAYSALEGATE_PG2.jpg"
[2]=>
string(11) "722_PG1.jpg"
[5]=>
string(16) "PWBY4_DELI-1.jpg"
[3]=>
string(17) "PW_PG2_COKE_A.jpg"
[4]=>
string(17) "PW_PG3_COKE_A.jpg"
}
Thanks
See Question&Answers more detail:os