Sorting files alphabetically with function directory_map - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Sorting files alphabetically with function directory_map (/showthread.php?tid=7683) |
Sorting files alphabetically with function directory_map - El Forum - 04-18-2008 [eluser]Unknown[/eluser] Hi my server filesystem does not sort files alphabetically - so my image list for my newsletter cms made in code igniter shows the images unordered. I've tried all sorts of sort code for the $filedata and nothing has worked - does anybody have any idea how to adjust this so my files are sorted properly? It's a big pain to have to scroll through the unordered list to select images! I think the culprit is in the file /system/helpers/directory_helper.php Code: function directory_map($source_dir, $top_level_only = FALSE) Sorting files alphabetically with function directory_map - El Forum - 04-18-2008 [eluser]Unknown[/eluser] ah my error here - this was an uber simple fix. I did switch to get_filenames instead of map_directory - probably not necessary - but the code to sort alphabetically is just this - in the systems/helpers/file_helper.php file before Code: return $_filedata; add Code: asort($_filedata); So instead looks like this: Code: asort($_filedata); Hope this can help somebody! Sorting files alphabetically with function directory_map - El Forum - 12-11-2008 [eluser]dsims[/eluser] you could also use Code: array_multisort($filedata); |