{"id":22377625,"url":"https://github.com/pimm/mapsort","last_synced_at":"2025-07-08T06:37:36.023Z","repository":{"id":35093708,"uuid":"179524998","full_name":"Pimm/mapsort","owner":"Pimm","description":"Performant sorting for complex input","archived":false,"fork":false,"pushed_at":"2024-09-01T18:15:52.000Z","size":1076,"stargazers_count":74,"open_issues_count":0,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-08T17:57:37.770Z","etag":null,"topics":["javascript","map","performance","sort"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Pimm.png","metadata":{"files":{"readme":"readme-nl.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"copying.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-04T15:24:33.000Z","updated_at":"2024-10-28T00:18:31.000Z","dependencies_parsed_at":"2023-01-15T13:41:18.402Z","dependency_job_id":"235e1ed5-ce8a-4134-944a-9e2ffb55344f","html_url":"https://github.com/Pimm/mapsort","commit_stats":{"total_commits":98,"total_committers":6,"mean_commits":"16.333333333333332","dds":0.05102040816326525,"last_synced_commit":"7ec4eb4ee7e9282a069b9ad6bb83f444f093598e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pimm%2Fmapsort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pimm%2Fmapsort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pimm%2Fmapsort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Pimm%2Fmapsort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Pimm","download_url":"https://codeload.github.com/Pimm/mapsort/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244006278,"owners_count":20382444,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","map","performance","sort"],"created_at":"2024-12-04T22:14:58.387Z","updated_at":"2025-03-17T09:09:27.801Z","avatar_url":"https://github.com/Pimm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mapsort \u0026middot; [![Licentie (X11/MIT)](https://badgen.net/github/license/pimm/mapsort)](https://github.com/Pimm/mapsort/blob/master/copying.txt) [![npm versie](https://badgen.net/npm/v/mapsort)](https://www.npmjs.com/package/mapsort) [![Test status](https://github.com/Pimm/mapsort/actions/workflows/test.yaml/badge.svg)](https://github.com/Pimm/mapsort/actions/workflows/test.yaml) [![Coverage status](https://coveralls.io/repos/github/Pimm/mapsort/badge.svg?branch=master)](https://coveralls.io/github/Pimm/mapsort?branch=master)\n\nEfficiënte sortering van complexe invoer.\n\n## Voorwoord\n\n**Je hebt deze bibliotheek niet nodig tenzij je problemen met prestaties hebt.** `mapsort` voegt geen functionaliteit toe die niet in kale JavaScript aanwezig is. Wel verbetert het je efficiëntie aanzienlijk als:\n\n* sorteren je bottleneck is, en\n* je dure verwerkingen moet toepassen op de elementen in je arrays voordat je hun correcte volgorde kunt bepalen.\n\n# Concept\n\nStel je voor dat we deze array van getallen sorteren, vertegenwoordigd als strings:\n```javascript\n['12', '1', '3.14']\n```\n`'12'` zou voor `'3.14'` worden geplaatst als we sorteren zonder vergelijkfunctie, dus zo een functie is vereist:\n```javascript\n['12', '1', '3.14'].toSorted((a, b) =\u003e parseFloat(a) - parseFloat(b));\n```\nDat werkt!\n\nHet nadeel is dat `parseFloat` twee keer wordt aangeroepen iedere keer dat onze vergelijkfunctie wordt gebruikt. Bij het sorteren van drie getallen wordt `parseFloat` 6 (of 4) keer aangeroepen, terwijl het met 3 keer ook kan.\n\n`parseFloat` 3 of 6 keer aanroepen maakt geen verschil. Maar in de toekomst sorteren we misschien namen. _Lucia Ávila_ wilt tussen de andere **A**'s staan, daarvoor moeten we rekening houden met [schrijftekens](https://nl.wikipedia.org/wiki/Diakritisch_teken). _Amelie de Wit_ wilt tussen de andere **W**'s staan, daarvoor moeten we [tussenvoegsels](https://nl.wikipedia.org/wiki/Tussenvoegsel) detecteren. En het aantal keren dat de vergelijkfunctie wordt gebruikt, groeit loglineair met het aantal namen. Als de verwerking die we moeten toepassen duurder wordt en de arrays langer, kan dit voelbare vertraging opleveren.\n\n`mapsort` beperkt het aantal keren dat een element wordt verwerkt tot 1:\n```javascript\nmapSort(['12', '1', '3.14'], parseFloat, (a, b) =\u003e a - b);\n```\n\n# Installatie\n\nInstalleer `mapsort` met npm of Yarn en importeer de functie:\n```javascript\nimport mapSort from 'mapsort';\n```\n\nAls alternatief kan `mapsort` ook worden binnengehaald met unpkg:\n```html\n\u003cscript src=\"https://unpkg.com/mapsort@^1.0.10\"\u003e\u003c/script\u003e\n```\nMet deze aanpak wordt de functie beschikbaar als `window.mapSort`.\n\n# Gebruik\n\n``` javascript\nconst sortedArray = mapSort(\n\tarray,\n\telement =\u003e {\n\t\t// Geef de versie van \"element\" terug die ideaal is\n\t\t// om te sorteren. Deze versie wordt doorgegeven aan\n\t\t// de vergelijkfunctie hieronder.\n\t},\n\t(a, b) =\u003e {\n\t\t// (Optioneel.) Geef een negatief getal terug als a\n\t\t// voor b hoort; een positief getal als b voor a hoort;\n\t\t// of 0 als ze gelijk zijn.\n\t}\n);\n```\n\n## Opmerkingen\n\n* Deze bibliotheek sorteert niet _in-place_, en lijkt daarmee meer op [`[].toSorted`][mdn-tosorted] dan [`[].sort`][mdn-sort].\n* Deze bibliotheek sorteert [waarschijnlijk][stable-sorting] stabiel.\n\n# Licentie (X11/MIT)\nCopyright (c) 2019-2023 Pimm \"de Chinchilla\" Hogeling, Edo Rivai\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\n**The Software is provided \"as is\", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.**\n\n\n[mdn-tosorted]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted\n[mdn-sort]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort\n[stable-sorting]: https://github.com/Pimm/mapsort/blob/master/documentation/stable-sorting-nl.md","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpimm%2Fmapsort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpimm%2Fmapsort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpimm%2Fmapsort/lists"}