How to sort strings in JavaScript

后端 未结 12 2055
生来不讨喜
生来不讨喜 2020-11-22 13:20

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) {
    retur         


        
12条回答
  •  抹茶落季
    2020-11-22 13:30

    var str = ['v','a','da','c','k','l']
    var b = str.join('').split('').sort().reverse().join('')
    console.log(b)
    

提交回复
热议问题