Every line of 'lodash sort array of objects' 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.
49 function sort(object) { 50 var sortable = []; 51 for (var key in object) { 52 sortable.push([key, object[key]]); 53 } 54 55 return sortable.sort(function(a, b) { 56 return b[1] - a[1]; 57 }); 58 }
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 }
54 function sortObjectArray(arr: T[]) { 55 return arr.sort(compareObjects); 56 }
64 function sortObject (arr) { 65 return arr.sort((a, b) => (a.index - b.index)) 66 }
8 export function sortObjectArray(array, sortKey, isAscending) { 9 const results = array.sort((rowDataA, rowDataB) => { 10 const a = rowDataA[sortKey]; 11 const b = rowDataB[sortKey]; 12 if (typeof a === 'string' && typeof b === 'string') { // If strings, sort case-insensitive 13 return a.toLowerCase().localeCompare(b.toLowerCase()); 14 } 15 // If any other type of object, e.g. a number, just use the natural ordering 16 if (a < b) return -1; 17 if (a > b) return 1; 18 return 0; 19 }); 20 if (!isAscending) return results.reverse(); 21 return results; 22 }
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 }
716 function sort(array) { 717 return array.sort(sortFn); 718 }
229 function sort(array) { return array.sort(sortFn); }