2

I have an array of strings, which might contain numbers represented as strings.

var data = ['BK1125', '5', '3', '2', '1', '11', '001', 'BK123', 'BK121', '4']

Now, I want to sort it so that final output should be

var data = ['001', '1', '2', '3', '4','5','11','BK121', 'BK123', 'BK1125']

I understand that plain sort() function will not be able to do it. I tried to look at many answers but still didn't get the expected results.

Thanks in advance.

ScrapCode
  • 2,109
  • 5
  • 24
  • 44

0 Answers0