Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
150
rated 0 times [  157] [ 7]  / answers: 1 / hits: 17947  / 9 Years ago, mon, january 11, 2016, 12:00:00
_.sortBy(arrData, rhid);


This code sorts array but as the values of field rhid are strings the order is messed up.
How can i sort as if rhid where int field.



Thanks


More From » arrays

 Answers
5

sortBy can be used with a function instead of a property name.



_.sortBy(arrData, function (obj) {
return parseInt(obj.rhid, 10);
});

[#63769] Friday, January 8, 2016, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
toddbrandtc

Total Points: 400
Total Questions: 104
Total Answers: 90

Location: Antigua and Barbuda
Member since Wed, Aug 4, 2021
3 Years ago
;