From 3ebc83c133a8711cdf3afc2ac41be7004131216d Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Mon, 3 Jul 2023 20:19:39 +0200 Subject: [PATCH] Do not ignore punctuation when sorting features fix #1189 --- umap/static/umap/js/umap.core.js | 1 - umap/static/umap/test/Util.js | 9 +++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/umap/static/umap/js/umap.core.js b/umap/static/umap/js/umap.core.js index d2540fba..a255df5b 100644 --- a/umap/static/umap/js/umap.core.js +++ b/umap/static/umap/js/umap.core.js @@ -221,7 +221,6 @@ L.Util.sortFeatures = (features, sortKey) => { .toLowerCase() .localeCompare(valB.toString().toLowerCase(), L.locale || 'en', { sensitivity: 'base', - ignorePunctuation: true, numeric: true, }) } diff --git a/umap/static/umap/test/Util.js b/umap/static/umap/test/Util.js index 77418be0..d9555430 100644 --- a/umap/static/umap/test/Util.js +++ b/umap/static/umap/test/Util.js @@ -496,5 +496,14 @@ describe('L.Util', function () { assert.equal(features[1], feat2) assert.equal(features[2], feat3) }) + it('should sort feature with space first', function () { + feat1.properties.mykey = "1 foo" + feat2.properties.mykey = "2 foo" + feat3.properties.mykey = "1a foo" + let features = L.Util.sortFeatures([feat1, feat2, feat3], "mykey") + assert.equal(features[0], feat1) + assert.equal(features[1], feat3) + assert.equal(features[2], feat2) + }) }) })