kentcdodds / match-sorter

Simple, expected, and deterministic best-match sorting of an array in JavaScript
https://npm.im/match-sorter
MIT License
3.73k stars 129 forks source link

fix: sort objects by matched key only (fixes #78) #79

Closed bernharduw closed 5 years ago

bernharduw commented 5 years ago

What:

When using multiple keys to filter objects, the objects are always sorted by the last key in the list (if the ranks are otherwise equal), no matter which key actually matched. This PR fixes that behavior.

Why:

Sorting by last key is unexpected and most probably unintended py the original PR.

How:

I set the key to be sorted on to the one that actually matched.

Checklist:

kentcdodds commented 5 years ago

In retrospect this can be considered more of a bugfix than a breaking change 👍 Thank you!

kentcdodds commented 5 years ago

:tada: This PR is included in version 4.0.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: