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
string | number | booleanthe current rank.
string | number | booleanthe other rank thats after the current rank.
Returns
stringthe 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
string | number | booleanthe first rank.
string | number | booleanthe second rank.
Returns
string0, -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
string | number | booleanthe current rank.
Returns
stringthe next rank.
genPrev
genPrev(
pCurrent):string
Generates the previous rank from the provided current rank. e.g. genPrev("0|zzzzzz:") returns "0|y00000:"
Parameters
string | number | booleanthe current rank.
Returns
stringthe previous rank.
getBucket
getBucket(
pRank):string
Returns the bucket of the provided rank. e.g. getBucket("2|zzzzzz:") returns "2".
Parameters
string | number | booleanthe rank.
Returns
stringthe 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
string | number | booleanReturns
stringthe 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
string | number | booleanthe current rank.
Returns
stringthe 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
string | number | booleanthe current rank.
Returns
stringthe 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
string | number | booleanthe rank to check.
Returns
booleantrue 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
string | number | booleanthe rank to check.
Returns
booleantrue if the provided rank is the smallest rank.
max
max():
string
Returns the largest possible rank ("0|zzzzzz:").
Returns
stringthe largest rank.
middle
middle():
string
Returns the rank that's in between the min and max rank ("0|hzzzzz:").
Returns
stringthe middle rank.
min
min():
string
Returns the smallest possible rank ("0|000000:").
Returns
stringthe smallest possible rank.