Function hashSort

  • hash sort function

    Type Parameters

    • T

    Parameters

    • collection: T[]

      array collection

    • Optional indexer: Indexer<T>

      extract numeric index from each item of collection

      Optional
    • reverse: boolean = false

      reverse the sort order (DESC)

    Returns T[]

    the sorted list

    Since

    5.21.0

    Example

    hashSort([2, 999, 3, 113, 3, 32, 3, 4])
    // [2, 3, 3, 3, 4, 32, 113, 999]

    hashSort(
    [
    { age: 2 },{ age: 999 },{ age: 3 },
    { age: 113 },{ age: 3 },{ age: 32 },
    { age: 3 },{ age: 4 }
    ],
    (item) => item.age
    )
    // [
    // { age: 2 },{ age: 3 },{ age: 3 },
    // { age: 3 },{ age: 4 },{ age: 32 },
    // { age: 113 },{ age: 999 }
    // ]