sort algorithm via js