Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Legal Description Sorting Algorithm
(version: 0)
Comparing performance of:
Previous vs MyOwn
Created:
6 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script>
Script Preparation code:
searchResults = [ { county: "Adair", state: "Oklahoma", "region-type": "county", kind: "county", id: "-iYA92cBn26Nb0KrJNh5" }, { meridian: "IM", county: "Adair", range: "24E", state: "Oklahoma", "region-type": "township", township: "16N", kind: "township", id: "HCkd92cBn26Nb0KrKubx" }, { meridian: "IM", county: "Adair", range: "25E", state: "Oklahoma", "region-type": "township", township: "17N", kind: "township", id: "0Ckd92cBn26Nb0KrKuXx" }, { meridian: "IM", county: "Adair", range: "25E", state: "Oklahoma", "region-type": "township", township: "15N", kind: "township", id: "WSkd92cBn26Nb0KrKubx" }, { meridian: "IM", county: "Adair", range: "26E", state: "Oklahoma", "region-type": "township", township: "18N", kind: "township", id: "oCkd92cBn26Nb0KrKuXx" }, { meridian: "IM", county: "Adair", range: "27E", state: "Oklahoma", "region-type": "township", township: "15N", kind: "township", id: "Yykd92cBn26Nb0KrKubx" }, { meridian: "IM", county: "Adair", range: "25E", state: "Oklahoma", "region-type": "township", township: "19N", kind: "township", id: "bCkd92cBn26Nb0KrKuXx" }, { meridian: "IM", county: "Adair", range: "24E", state: "Oklahoma", "region-type": "township", township: "18N", kind: "township", id: "pikd92cBn26Nb0KrKuXx" }, { meridian: "IM", county: "Adair", range: "24E", state: "Oklahoma", "region-type": "township", township: "14N", kind: "township", id: "fykd92cBn26Nb0KrKubx" }, { meridian: "IM", county: "Adair", range: "27E", state: "Oklahoma", "region-type": "township", township: "14N", kind: "township", id: "gikd92cBn26Nb0KrKubx" }, { meridian: "IM", county: "Adair", range: "25E", state: "Oklahoma", "region-type": "township", township: "14N", kind: "township", id: "kSkd92cBn26Nb0KrKubx" }, { meridian: "IM", county: "Adair", range: "25E", section: "17", state: "Oklahoma", "region-type": "section", township: "18N", kind: "section", id: "PCkZ92cBn26Nb0KrfDOO" }, { meridian: "IM", county: "Adair", range: "25E", section: "16", state: "Oklahoma", "region-type": "section", township: "16N", kind: "section", id: "PCkZ92cBn26Nb0KrfEKa" }, { meridian: "IM", county: "Adair", range: "24E", section: "23", state: "Oklahoma", "region-type": "section", township: "16N", kind: "section", id: "PCkZ92cBn26Nb0KrfEOb" }, { meridian: "IM", county: "Adair", range: "26E", section: "16", state: "Oklahoma", "region-type": "section", township: "18N", kind: "section", id: "PSkZ92cBn26Nb0KrfDOO" }, { meridian: "IM", county: "Adair", range: "26E", section: "19", state: "Oklahoma", "region-type": "section", township: "14N", kind: "section", id: "PSkZ92cBn26Nb0KrfFKk" }, { meridian: "IM", county: "Adair", range: "24E", section: "20", state: "Oklahoma", "region-type": "section", township: "19N", kind: "section", id: "PikX92cBn26Nb0KrTS2_" }, { meridian: "IM", county: "Adair", range: "24E", section: "06", state: "Oklahoma", "region-type": "section", township: "16N", kind: "section", id: "PikZ92cBn26Nb0KrfD-Y" }, { meridian: "IM", county: "Adair", range: "26E", section: "05", state: "Oklahoma", "region-type": "section", township: "16N", kind: "section", id: "QSkZ92cBn26Nb0KrfD-Y" } ]
Tests:
Previous
const createTownshipSortString = function( region, existingSort ) { // Unique case, always put CM meridian at bottom. const meridian = region.meridian === 'CM' ? 'Z' : region.meridian; return ( existingSort + meridian + region.county + region.township + region.range ); } const sortResults = function(searchResults) { return _.sortBy(searchResults, result => { // Sort counties at top. const regionSort = result.kind === 'county' ? '1' : '3'; const townshipSort = result.kind === 'township' ? '2' : '3'; const sortStr = `${regionSort}${townshipSort}`; switch (result.kind) { case 'survey': return ( sortStr + result.county + result.survey + result.block + result.section + result.abstract ); case 'county': return sortStr; case 'township': return createTownshipSortString(result, sortStr); case 'section': return createTownshipSortString(result, sortStr) + result.section; } }); } sortResults(searchResults)
MyOwn
const sortResults2 = function(searchResults) { const groupedResults = _.groupBy(searchResults, 'kind'); const orderedSurveys = _.orderBy(groupedResults.survey, ['county', 'survey', 'block', 'section', 'abstract'], 'asc'); const orderedCounties = _.orderBy(groupedResults.county, 'county', 'asc'); // Unique case, always put CM meridian at bottom. const orderedTownships = _.orderBy(groupedResults.township, ['meridian', 'township', 'range'], ['desc', 'asc', 'asc']); const orderedSections = _.orderBy(groupedResults.section, ['meridian', 'section', 'township', 'range'], ['desc', 'asc', 'asc', 'asc']); const collatedSearchResults = [...orderedCounties, ...orderedTownships, ...orderedSurveys, ...orderedSections]; } sortResults2(searchResults)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Previous
MyOwn
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'm ready to help! Please provide the specific question or task you'd like me to assist with, and I'll do my best to answer it accurately and efficiently.
Related benchmarks:
Lodash.isEqual vs JSON.stringify Equality Comparison for Deep Array of Strings more data.
_.isEqual vs JSON.stringify big
Lodash.isEqual vs JSON.stringify Equality Comparison for Large Deep Object.
Lodash.isEqual vs JSON.stringify Equality Comparison for array of objects with nested properties and lots of records 222weqeqrq
Lodash_4.17.21.sortBy vs .sort vs custom
Comments
Confirm delete:
Do you really want to delete benchmark?