Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: groupBy abc should be alphabetical

thecodrr524b49db22d3
diff --git a/packages/core/api/database.js b/packages/core/api/database.js
index eb842d0be..12b4cb68c 100644
--- a/packages/core/api/database.js
+++ b/packages/core/api/database.js
@@ -69,7 +69,12 @@ class Database {
let notes = this.getNotes();
switch (by) {
case "abc":
- return groupBy(notes, note => note.title[0].toUpperCase(), special);
+ let groups = groupBy(
+ notes.sort((a, b) => a.title.localeCompare(b.title)),
+ note => note.title[0].toUpperCase(),
+ special
+ );
+ return groups;
case "month":
return groupBy(
notes,
diff --git a/packages/core/utils/index.js b/packages/core/utils/index.js
index 071605473..1408c521c 100644
--- a/packages/core/utils/index.js
+++ b/packages/core/utils/index.js
@@ -43,7 +43,7 @@ function groupBySpecial(arr, key) {
_groups[k] == undefined ? groupCounts.length : _groups[k].groupIndex;
retVal.splice(index, 0, val);
groupCounts[groupIndex] =
- groupCounts.length == groupIndex ? 1 : groupCounts[groupIndex]++;
+ groupCounts.length == groupIndex ? 1 : groupCounts[groupIndex] + 1;
groups[groupIndex] = { title: k };
_groups[k] = {
index: i,