Skip to main content
Version: 2025.2

lexorank

JScript wrapper for the LexoRank sorting algorithm.

Methods​

between​

between(pCurrent, pOther): string

Return the rank thats between pCurrent and pOther. e.g. between("0|000000:", "0|zzzzzz:") returns "0|hzzzzz:"

Parameters​

pCurrent
string | number | boolean

the current rank.

pOther
string | number | boolean

the other rank thats after the current rank.

Returns​

string

the rank that's between pCurrent and pOther.


compare​

compare(pRank1, pRank2): string

Compares 2 ranks and returns 0 if the ranks are equal, -1 if rank1 is before rank2 and 1 if rank2 is before rank1.

Parameters​

pRank1
string | number | boolean

the first rank.

pRank2
string | number | boolean

the second rank.

Returns​

string

0, -1 or 1 depending upon if the ranks are equal, rank1 is before rank2 or rank2 is before rank1.


genNext​

genNext(pCurrent): string

Generates the next rank from the provided current rank. e.g. genNext("0|000000:") returns "0|100000:"

Parameters​

pCurrent
string | number | boolean

the current rank.

Returns​

string

the next rank.


genPrev​

genPrev(pCurrent): string

Generates the previous rank from the provided current rank. e.g. genPrev("0|zzzzzz:") returns "0|y00000:"

Parameters​

pCurrent
string | number | boolean

the current rank.

Returns​

string

the previous rank.


getBucket​

getBucket(pRank): string

Returns the bucket of the provided rank. e.g. getBucket("2|zzzzzz:") returns "2".

Parameters​

pRank
string | number | boolean

the rank.

Returns​

string

the bucket of the provided rank.


initial​

initial(pBucket?): string

Returns the initial rank of the provided bucket. e.g. initial("2") returns "2|y00000:"

Parameters​

pBucket?
string | number | boolean

Returns​

string

the initial rank for the provided bucket.


inNextBucket​

inNextBucket(pCurrent): string

Moves to current rank to the next bucket. Only 3 buckets are supported (0, 1, 2) and are rotated in a round-robin way. e.g. inNextBucket("0|000000:") returns "1|000000:"

Parameters​

pCurrent
string | number | boolean

the current rank.

Returns​

string

the current rank + 1 bucket.


inPrevBucket​

inPrevBucket(pCurrent): string

Moves to current rank to the previous bucket. Only 3 buckets are supported (0, 1, 2) and are rotated in a round-robin way. e.g. inNextBucket("0|000000:") returns "2|000000:"

Parameters​

pCurrent
string | number | boolean

the current rank.

Returns​

string

the current rank - 1 bucket.


isMax​

isMax(pRank): boolean

Checks if the provided rank is the largest possible rank. e.g. isMin("0|zzzzzz:") returns true.

Parameters​

pRank
string | number | boolean

the rank to check.

Returns​

boolean

true if the provided rank is the largest rank.


isMin​

isMin(pRank): boolean

Checks if the provided rank is the smallest possible rank. e.g. isMin("0|000000:") returns true.

Parameters​

pRank
string | number | boolean

the rank to check.

Returns​

boolean

true if the provided rank is the smallest rank.


max​

max(): string

Returns the largest possible rank ("0|zzzzzz:").

Returns​

string

the largest rank.


middle​

middle(): string

Returns the rank that's in between the min and max rank ("0|hzzzzz:").

Returns​

string

the middle rank.


min​

min(): string

Returns the smallest possible rank ("0|000000:").

Returns​

string

the smallest possible rank.