On Friday, 29 May 2020 at 00:32:13 UTC, mw wrote: > > If you don’t care the remaining elements’ order, just swap the > head N elements with the index array’s pointing to. (unstable > swap, linear to N=index.length) Note: If index[i] < index.length, don’t swap that element.