Skip to content

Commit b6bfe29

Browse files
committed
localCompare can be used in custom functions
1 parent 86790ca commit b6bfe29

File tree

1 file changed

+1
-13
lines changed

1 file changed

+1
-13
lines changed

index.js

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,12 @@ function sortBy(props, opts) {
7878
*/
7979

8080
function compare(prop, a, b) {
81-
// custom function
8281
if (typeof prop === 'function') {
8382
// expose `compare` to custom function
8483
return prop(a, b, compare.bind(null, null));
8584
}
86-
87-
// compare strings
88-
if (typeof a === 'string' && typeof b === 'string') {
89-
return a.localeCompare(b);
90-
}
91-
92-
// compare numbers
93-
if (typeOf(a) === 'number' && typeOf(b) === 'number') {
94-
return a - b;
95-
}
96-
9785
// compare object values
98-
if (prop && typeOf(a) === 'object' && typeOf(b) === 'object') {
86+
if (prop && typeof a === 'object' && typeof b === 'object') {
9987
return compare(null, get(a, prop), get(b, prop));
10088
}
10189
return defaultCompare(a, b);

0 commit comments

Comments
 (0)