« get me outta code hell

content: generateArtistInfoPageArtworksChunkedList - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/util
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-06-26 10:23:37 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-06-26 10:23:37 -0300
commit168fd6d42dafa6832f6f5d4c52f23c6d57cba082 (patch)
treefa29e5942478079ad8da3eee9259dfed45091766 /src/util
parent160c6c4c92f0c574981bab9fabd5f2d06cb0bf10 (diff)
content: generateArtistInfoPageArtworksChunkedList
Diffstat (limited to 'src/util')
-rw-r--r--src/util/wiki-data.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/util/wiki-data.js b/src/util/wiki-data.js
index 382f1620..da8312f9 100644
--- a/src/util/wiki-data.js
+++ b/src/util/wiki-data.js
@@ -343,6 +343,33 @@ export function sortEntryThingPairs(data, sortFunction) {
   return data;
 }
 
+/*
+// Alternate draft version of sortEntryThingPairs.
+// See: https://github.com/hsmusic/hsmusic-wiki/issues/90#issuecomment-1607412168
+
+// Maps the provided "preparation" function across a list of arbitrary values,
+// building up a list of sortable values; sorts these with the provided sorting
+// function; and reorders the sources to match their corresponding prepared
+// values. As usual, if multiple source items correspond to the same sorting
+// data, this retains the source relative positioning.
+export function prepareAndSort(sources, prepareForSort, sortFunction) {
+  const prepared = [];
+  const preparedToSource = new Map();
+
+  for (const original of originals) {
+    const prep = prepareForSort(source);
+    prepared.push(prep);
+    preparedToSource.set(prep, source);
+  }
+
+  sortFunction(prepared);
+
+  sources.splice(0, ...sources.length, prepared.map(prep => preparedToSource.get(prep)));
+
+  return sources;
+}
+*/
+
 // Highly contextual sort functions - these are only for very specific types
 // of Things, and have appropriately hard-coded behavior.