yaqwsx / jlcparts

Better parametric search for components available for JLC PCB assembly
https://yaqwsx.github.io/jlcparts/
MIT License
572 stars 52 forks source link

Natural sorting of properties #66

Closed maksz42 closed 2 years ago

maksz42 commented 2 years ago

Some values are messed up (ordered alphabetically), for example, 'Maximum Clamping Voltage' of 'Circuit Protection/TVS': obraz I tried localeCompare with {numeric: true} and it was better but still not perfect: obraz I found "@discoveryjs/natural-compare" package and it seems to work just fine: obraz

yaqwsx commented 2 years ago

Thanks for the PR. The original idea of the project was to parse the data in backend, normalize them and present them in uniform form. Therefore, if your original intention is to fix problem of the fields 'Maximum Clamping Voltage' and 'Circuit Protection/TVS' I suggest a "better" fix: adding them to this list: https://github.com/yaqwsx/jlcparts/blob/17adb09b9d9b3289dead846d93f94c2c360dd81b/jlcparts/datatables.py#L66

Overall, I like the idea of the fallback solution (string compare) behaving more reasonable.

maksz42 commented 2 years ago

TVS was just an example. I think we can't parse/normalize every single property so at least the default sorting could be better.

yaqwsx commented 2 years ago

I think we can - it is just laborious (we already support an arbitrary field format with multiple values in various units).