image-js
Version:
Image processing and manipulation in JavaScript
15 lines (13 loc) • 416 B
text/typescript
import type { Match } from '../matching/bruteForceMatch.js';
/**
* Source array of matches by ascending distance.
* @param matches - Array of matches to sort.
* @returns Sorted copy of the array of matches.
*/
export function sortByDistance(matches: Match[]): Match[] {
const sorted = matches.slice();
sorted.sort((match1, match2) => {
return match1.distance - match2.distance;
});
return sorted;
}