Table-sorting in JS