Search without sorting
See original GitHub issueHi there,
I have a large select with years. Let’s say 1900 until 2018. And add them with setChoices()
. The items are already sorted so they do not need to be sorted again.
Two things:
- If I add the years as integers the search is not giving any results. If I add them as strings it is working. Not a big deal and that is not what this issue is about.
- If I search with string
20
the first result is 2009 and after that is is nicely sorted as expected: 2018, 2017, 2016, 2015, etc. The same thing happens when I search on19
: the first record is1949
and after that the results are 1999, 1998 is missing (is somewhere below) 1997, 1996, 1995, 1994, etc.
I can’t see why this is happening. As far as I can see the results from fuse are correctly sorted (read: unchanged).
new Choices(document.getElementById('select'), {
shouldSort: false,
silent: true,
searchResultLimit: 100,
itemSelectText: '',
fuseOptions: {
shouldSort: false,
includeScore: false,
includeMatches: false,
threshold: 0,
location: 0,
distance: 100,
maxPatternLength: 32,
minMatchCharLength: 1,
keys: ["value"]
}
});
See also this example https://plnkr.co/edit/d1hsGPour408YC5OqVSf?p=preview v3.0.3
Is there any way to just keep the sorting as it is?
Issue Analytics
- State:
- Created 6 years ago
- Comments:5
Top Results From Across the Web
Fastest way to search for an element in unsorted array
You start off by sorting the array using the merge sort algorithm, then you use binary search to find the element. Both algoro...
Read more >How do I search for an element in an array without sorting?
The most straightforward way is to do exactly that: take one pass to identify the largest element, and a second pass to identify...
Read more >Rearrange Array to find K using Binary Search algorithm ...
Rearrange Array to find K using Binary Search algorithm without sorting ; Find the mid point of the current range [L, R] as...
Read more >Excel Lookup without sorting Table - Possible?
Lookup requires that the table (lookup vector) be sorted by the lookup field (value). Is there a method or other formula that does...
Read more >Algorithms: Searching and Sorting Cheatsheet
Binary search performs the search for the target within a sorted array. Hence, to run a binary search on a dataset, it must...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We’re still on v2.7.8, but here’s an edit we’re thinking about making to our environment (eventually doing a PR):
secondarySortByAlpha
sortByScore
to be:So, here, in cases of a close match (two decimal points) they would be sorted alphabetically – which I imagine would do similarly for number labels.
Before:
After:
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.