Some sort algorithm in js