10 examples of 'comparator in javascript' in JavaScript

Every line of 'comparator in javascript' 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.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
79function compare (a, b)
80{
81 var
82 vertices = compare .vertices;
83 axis = compare .axis;
84
85 return Math .min (vertices [a + axis], vertices [a + 4 + axis], vertices [a + 8 + axis]) <
86 Math .min (vertices [b + axis], vertices [b + 4 + axis], vertices [b + 8 + axis]);
87}
113function comparator(a, b)
114{
115 return a.url.localeCompare(b.url);
116}
162function comparator(a, b)
163{
164 return a.data[sortColumnIdentifier].localeCompare(b.data[sortColumnIdentifier]);
165}
1605function sorter(a, b)
1606{
1607 return a.name.compareTo(b.name);
1608}
72function compare(a, b, isAsc) {
73 return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
74}
36comparator(a, b) { // sort by path-length, and then lexically by attribute name.
37 return (cmp(partsLen, a, b)) || (cmp(displayName, a, b));
38}
123data.drilldownData[j].data.sort(function compare(a, b) {
124 if (a[1] > b[1]) {
125 return -1;
126 } else if (a[1] < b[1]) {
127 return 1;
128 }
129 return 0;
130});
460})).sort(function compare(a, b) {
461 if (a.sort < b.sort)
462 return -1;
463 if (a.sort > b.sort)
464 return 1;
465 return 0;
466}),
34function sort(a, b) {
35 const first = a.data.order;
36 const second = b.data.order;
37
38 // Ensure the sort returns the same list when there are files with the same `order` value.
39 // Otherwise we might have a different ordering of the TOC.
40 if (first === second) {
41 return JSON.stringify(a).localeCompare(JSON.stringify(b));
42 }
43
44 if (typeof first !== 'number') {
45 return 1;
46 }
47
48 if (typeof second !== 'number') {
49 return -1;
50 }
51
52 return first - second;
53}
169function comparator(a, b)
170{
171 var item1 = a.layer[sortColumnIdentifier] || 0;
172 var item2 = b.layer[sortColumnIdentifier] || 0;
173 return item1 - item2;
174}

Related snippets