0

How do i make this alpha sort not case sensitive? I understand that you should use to toLowerCase but I don't know how.

sort_alpha: function(a,b) {
    if (a[0]==b[0]) return 0;
    if (a[0]<b[0]) return -1;
    return 1;
}
isherwood
  • 58,414
  • 16
  • 114
  • 157
Heinzer
  • 11
  • 2

1 Answers1

0

You need to turn a and b into lower case

var lower_a = a.toLowerCase();
var lower_b = b.toLowerCase();
gbvisconti
  • 412
  • 1
  • 4
  • 19
  • why duplicate each value twice into a var? doing so only increases ram and cpu costs while lowering stability... – dandavis Sep 10 '14 at 18:00
  • I agree, ram is a critical issue nowadays. I just wrote that way to be more clear. Now if he wants to create two more variables it's up to him. – gbvisconti Sep 10 '14 at 18:11