modified sorting js to new layout