I've encountered weird stuff that I can't understand and figure out.
I'm trying to sort the table (ascending/descending) - the thing is, it doesn't work as it is supposed to. I've tried debugging and still have no idea why it doesn't work despite code being correct (I think ).
This is the tutorial code that I've used
Everything works great in tutorial, and nothing works for me.
Here is my table before sorting:
Here is my table after sorting (supposedly ascending):
My code is exactly the same as in the tutorial, I've changed nothing in the original function.
During debugging I've noticed that the problem seems to be at this line:
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase())
which returns true, right in the first iteration (and it shouldn't, since becouse of that my table row ,,Learn ReactJs'' gets moved bottom, and ,,Zinish frontend project'' is moved in first place in table)
I tried changing the ,,greater'' symbol to ,,lower'' symbol, however that doesn't help. I also tried adding:
if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) {
shouldSwitch = true;
break;
} else { shouldSwitch = false;}
But it also doesn't help. I don't know why it won't work. Please help..
edit: here's pen of my table with the function itself
https://codepen.io/anon/pen/rJQJKx