I am developing an application using Reactjs and underscore.js . I am trying to sort a list using name which is a string. However, the names contains numbers, as a result the sorting is not right. Here is an example of my code and its result:
items= _.sortBy(items, function (item) {
return item.name.toLowerCase()
});
Result:
S1.2M (FA)
S10.1M
S10.2M
S10.4M
S11 (GR14)
S2 (DT)
S3.1M (GR17)
but I want the result, to be like this :
S1.2M (FA)
S2 (DT)
S3.1M (GR17)
S10.1M
S10.2M
S10.4M
S11 (GR14)
how can I achieve this?