Function sort_strings_by_rating_and_position

  • Sort array of strings by separate dictionary of ratings and also by position in array. Items at front of array will be rated higher.

    Parameters

    • arr: string[]

      array of strings to be sorted

    • ratings: SortRatings

      dictionary of {string:rating} ratings does not have to contain an entry for each arr item if missing, will be given default 0 likewise, it may contain more entries than arr, extras will be ignored

    • multiply_position: number = 1

      make position x times more important than rating (default 1) It's kind of backwards - Make it less than 1 to make rating more important. 0.5 is a good start. Just need to try it until you get a good value. In a very long list, ok to make it 0.1 or even 0.01.

    • immutable: boolean = false

      By default, this function will modify the arr, using arr.sort(). Set true to make this a pure function.

    Returns string[]

Generated using TypeDoc