code style would have `sorted[Math.ceil(idx) - 1]`