Quick Links
  • -Overview
  • -Language Features
  • -JS Interop
  • -Build System
Documentation
Language Manual
Reference for all language features
ReScript & React
First class bindings for ReactJS
GenType
Seamless TypeScript integration
Reanalyze
Dead Code & Termination analysis
Exploration
Packages
Explore third party libraries and bindings
Syntax Lookup
Discover all syntax constructs
APIPlaygroundBlogCommunity
  • Playground
  • Blog
  • X
  • BlueSky
  • GitHub
  • Forum
Belt Stdlib
Overview
  • Introduction
Basics
  • Array
  • List
  • Float
  • Int
  • Range
  • Id
  • Option
  • Result
Set
  • HashSet
  • HashSetInt
  • HashSetString
  • Set
  • SetDict
  • SetInt
  • SetString
Map
  • HashMap
  • HashMapInt
  • HashMapString
  • Map
  • MapDict
  • MapInt
  • MapString
Mutable Collections
  • MutableMap
  • MutableMapInt
  • MutableMapString
  • MutableQueue
  • MutableSet
  • MutableSetInt
  • MutableSetString
  • MutableStack
Sort Collections
  • SortArray
  • SortArrayInt
    • binarySearch
    • element
    • isSorted
    • stableSort
    • stableSortInPlace
    • strictlySortedLength
  • SortArrayString
Utilities
  • Debug
API / Belt / SortArrayInt

SortArrayInt

This is a specialized module for Belt.SortArray, the docs in that module also applies here, except the comparator is fixed and inlined.

element

RES
type element = int

strictlySortedLength

RES
let strictlySortedLength: array<element> => int

The same as Belt.SortArray.strictlySortedLength except the comparator is fixed.

Returns +n means increasing order -n means negative order.

isSorted

RES
let isSorted: array<element> => bool

sorted(xs) return true if xs is in non strict increasing order.

stableSortInPlace

RES
let stableSortInPlace: array<element> => unit

The same as Belt.SortArray.stableSortInPlaceBy except the comparator is fixed.

stableSort

RES
let stableSort: array<element> => array<element>

The same as Belt.SortArray.stableSortBy except the comparator is fixed.

binarySearch

RES
let binarySearch: (array<element>, element) => int

If value is not found and value is less than one or more elements in array, the negative number returned is the bitwise complement of the index of the first element that is larger than value.

If value is not found and value is greater than all elements in array, the negative number returned is the bitwise complement of (the index of the last element plus 1)

for example, if key is smaller than all elements return -1 since lnot(-1) = 0 if key is larger than all elements return - (len + 1) since lnot(-(len+1)) = len.

© 2024 The ReScript Project

Software and assets distribution powered by KeyCDN.

About
  • Community
  • ReScript Association
Find us on