I have a list of objects I wish to sort based on a field attr
of type string. I tried using -
list.sort(function (a, b) {
return a.attr - b.attr
})
but found that -
doesn't appear to work with strings in JavaScript. How can I sort a list of objects based on an attribute with type string?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…