import { Comparator } from '../types'; /** * The `Selection` class provides static methods for sorting an * array using selection sort. * This implementation makes ~ ½ n2 compares to sort * any array of length n, so it is not suitable for sorting large arrays. * It performs exactly n exchanges. *

* This sorting algorithm is not stable. It uses Θ(1) extra memory * (not including the input array). *

* For additional documentation, see * Section 2.1 * of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne. */ export default class Selection { /** * Rearranges the array in ascending order, using a comparator. * @param a the array * @param comparator the comparator specifying the order */ static sort(a: any[], comparator?: Comparator): void; /** * `sort` method implemented `StringComparator` * @param a */ static sortString(a: any[]): void; /** * `sort` method implemented `NumberComparator` * @param a */ static sortNumber(a: any[]): void; private static less; private static exch; /** * Check if array is sorted - useful for debugging. * Is the array sorted from a[lo] to a[hi] */ private static isSorted; private static show; /** * Reads in a sequence of strings from standard input; selection sorts them; * and prints them to standard output in ascending order. * * @param args the command-line arguments */ static main(): void; }