Every line of 'how to sort an array without using sort method' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.
229 function sort(array) { return array.sort(sortFn); }
716 function sort(array) { 717 return array.sort(sortFn); 718 }
20 export function sort(array: T[]): T[] { 21 return array.sort((a, b) => (a.sortId === undefined || b.sortId === undefined) ? 0 : a.sortId - b.sortId); 22 }
1 export function sort(arr) { 2 return [...arr].sort((a, b) => a - b); 3 }
677 function noSort(array) { 678 return array; 679 }
277 function sort(arr) { 278 for (var i = 1; i < arr.length; i++) { 279 var tmp = arr[i] 280 var j = i 281 while (arr[j - 1] > tmp) { 282 arr[j] = arr[j - 1] 283 --j 284 } 285 arr[j] = tmp 286 } 287 288 return arr 289 }
978 function sort1(array) { 979 var len = array.length, 980 i, j, tmp, result; 981 982 // 赋予数组副本 983 result = array.slice(0); 984 for(i=1; i=0 && tmp < result[j]){ 985 result[j+1] = result[j]; 986 j--; 987 } 988 result[j+1] = tmp; 989 } 990 return result; 991 }
34 export default function sortBy(array, sortType, order) { 35 let sortedData = []; 36 37 switch (sortType) { 38 case 'attributes.last_released_at': 39 sortedData = array.sort(releasedAtSort); 40 break; 41 case 'newReleases': 42 sortedData = array.sort(releasedAtSort).sort(newReleasesSort); 43 break; 44 case 'attributes.title': 45 sortedData = array.sort(titleSort); 46 break; 47 default: 48 sortedData = array.sort(newReleasesSort); 49 } 50 51 if (order === 'descending') { return sortedData.reverse(); } 52 53 return sortedData; 54 }
8 function sort(object) { 9 if (sortArrays === true && Array.isArray(object)) { 10 return object.sort(); 11 } 12 else if (typeof object !== "object" || object === null) { 13 return object; 14 } 15 16 return Object.keys(object).sort().map(function (key) { 17 return { 18 key: key, 19 value: sort(object[key]) 20 }; 21 }); 22 }
7 function sort(object) { 8 if (sortArrays === true && Array.isArray(object)) { 9 return object.sort(); 10 } 11 else if (typeof object !== "object" || object === null) { 12 return object; 13 } 14 15 return Object.keys(object).sort().map(function(key) { 16 return { 17 key: key, 18 value: sort(object[key]) 19 }; 20 }); 21 }