Skip to content

tokenSortRatio

tokenSortRatio(a, b): number

Compute the token sort ratio between two strings.

Lower-cases both strings, splits them on whitespace, sorts the tokens and joins them with single spaces, then returns the normalized Levenshtein similarity of the two results, so word order does not matter. Punctuation is kept: Smith, and Smith are different tokens. Returns a value between 0.0 (completely different) and 1.0 (identical after sorting).

Parameter Type
a string
b string

number