import { IDirectoryItem } from "models" ; /**
 * Provides several static methods used for sorting a directory.
 */ export default { param unsortedItems returns sortByType ( unsortedItems ) { return unsortedItems . sort ( compareTypes ) ; } , param unsortedItems returns sortByAlphaNumery ( unsortedItems ) { return unsortedItems . sort ( ( a , b ) => a . name . localeCompare ( b . name ) ) ; } , param unsortedItems returns sortByTypeThenAlphaNumery ( unsortedItems ) { return unsortedItems . sort ( ( a , b ) => { const typeCompare = compareTypes ( a , b ) ; return typeCompare !== 0 ? typeCompare : a . name . localeCompare ( b . name ) ; } ) ; } } ; param a param b returns function compareTypes ( a , b ) { if ( a . isDirectory && ! b . isDirectory ) { return - 1 ; } else if ( b . isDirectory && ! a . isDirectory ) { return 1 ; } else { return 0 ; } }