« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index de0b214..5e6ef6e 100644
--- a/ui.js
+++ b/ui.js
@@ -60,6 +60,7 @@ const TuiTextEditor = require('tui-text-editor')
 
 const { promisify } = require('util')
 const { spawn } = require('child_process')
+const { orderBy } = require('natural-orderby')
 const fs = require('fs')
 const open = require('open')
 const path = require('path')
@@ -317,6 +318,7 @@ class AppElement extends FocusElement {
       {value: 'shuffle-groups', label: 'Shuffle order of groups'},
       {value: 'reverse', label: 'Reverse all'},
       {value: 'reverse-groups', label: 'Reverse order of groups'},
+      {value: 'alphabetic', label: 'Alphabetically'},
       {value: 'normal', label: 'In order'}
     ], this.showContextMenu)
 
@@ -1475,6 +1477,11 @@ class AppElement extends FocusElement {
         item = {items: flattenGrouplike(item).items.reverse()}
       } else if (order === 'reverse-groups') {
         item = reverseOrderOfGroups(item)
+      } else if (order === 'alphabetic') {
+        item = {
+          name: `${oldName} (alphabetic)`,
+          items: orderBy(flattenGrouplike(item).items, getNameWithoutTrackNumber)
+        }
       }
     } else {
       // Make it into a grouplike that just contains itself.