Skip to content

Instantly share code, notes, and snippets.

@kwylez
Created February 3, 2011 16:15
Show Gist options
  • Save kwylez/809701 to your computer and use it in GitHub Desktop.
Save kwylez/809701 to your computer and use it in GitHub Desktop.
<?php
// PHP version < 5.3
function compareFileName($a, $b, $keyToSortBy) {
return strnatcmp($a[$keyToSortBy], $b[$keyToSortBy]);
}
usort($arrayThatIsPopulated, 'compareFileName');
// PHP version >= 5.3
usort($arrayThatIsPopulated, function($a, $b, $keyToSortBy) {
return strnatcmp($a[$keyToSortBy], $b[$keyToSortBy]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment