iggs-utils - v2.4.0
    Preparing search index...

    Function isSorted

    • check if the givven array is sorted or not.

      Type Parameters

      • T

      Parameters

      • array: T[]

        array to check if is sorted

      • compareFn: (item1: T, item2: T) => number = genericSortFunction

        function to use for comparison operation

      Returns boolean

       isSorted([1,2,3])	//true
      isSorted([1,3,2]) //false
       isSorted(['a','b','c'])	//true
      isSorted(['a','c','b']) //false
       isSorted([{ x:1}, { x:2}, { x:3}], (o1,o2)=> o1.x-o2.x) // true
      isSorted([{ x:1}, { x:3}, { x:2}], (o1,o2)=> o1.x-o2.x) // false