โ† Acko questions
CodingReported in a candidate post, Sep 2020

Sort numbers by absolute difference from k, stable on ties

Filed under Acko

The question

Sort an array by each element's difference from k, keeping original order on equal differences (example [3,5,7,9,2,6], k=5 gives [5,6,3,7,2,9]).

No write-up yet. Related questions below have one.

Related Acko questions

Collected from public candidate posts and coding forums. Updated Nov 2026.