-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f7f574
commit f871201
Showing
6 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
import { featureCollection, feature, clustersKmeans } from '@turf/turf'; | ||
|
||
function prioritizeDistinctSort(arr) { | ||
const uniqueValues = []; | ||
const duplicatedValues = []; | ||
|
||
// Split the array into unique and duplicated values | ||
const countMap = {}; | ||
for (const item of arr) { | ||
if (countMap[item] === undefined) { | ||
countMap[item] = 1; | ||
uniqueValues.push(item); | ||
} else { | ||
countMap[item]++; | ||
duplicatedValues.push(item); | ||
} | ||
} | ||
|
||
// Sort unique values alphabetically | ||
uniqueValues.sort(); | ||
|
||
// Sort duplicated values alphabetically | ||
duplicatedValues.sort(); | ||
|
||
// Concatenate unique and duplicated values | ||
const result = [...uniqueValues, ...duplicatedValues]; | ||
return result; | ||
} | ||
|
||
export default { | ||
featureCollection, | ||
feature, | ||
clustersKmeans | ||
clustersKmeans, | ||
prioritizeDistinctSort | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
clouds/snowflake/modules/test/clustering/fixtures/st_clusterkmeans_out_points1.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
clouds/snowflake/modules/test/clustering/fixtures/st_clusterkmeans_out_points2.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
clouds/snowflake/modules/test/clustering/fixtures/st_clusterkmeans_out_points3.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.