import { asc } from "./asc"; /** * Returns a new array with `array[index]` replaced by `newValue` and the * result sorted ascending. Used by range-slider logic to normalize thumb * positions after a single-thumb move — crossing a neighbour reorders the * array so thumb-to-index mapping stays stable. */ export function replaceArrayItemAtIndex( array: readonly number[], index: number, newValue: number, ): number[] { const output = array.slice(); output[index] = newValue; return output.sort(asc); }