Modified sorting JS