diff --git a/js/actionCreators.js b/js/actionCreators.js
index 387a78d0..6f900e9e 100644
--- a/js/actionCreators.js
+++ b/js/actionCreators.js
@@ -4,7 +4,13 @@ import skinParser from "./skinParser";
import { BANDS } from "./constants";
import { getEqfData } from "./selectors";
-import { clamp, base64FromArrayBuffer, downloadURI, normalize } from "./utils";
+import {
+ clamp,
+ base64FromArrayBuffer,
+ downloadURI,
+ normalize,
+ sort
+} from "./utils";
import {
CLOSE_WINAMP,
LOAD_AUDIO_FILE,
@@ -25,7 +31,10 @@ import {
CLOSE_EQUALIZER_WINDOW,
REMOVE_TRACKS,
PLAY,
- PAUSE
+ PAUSE,
+ REVERSE_LIST,
+ RANDOMIZE_LIST,
+ SET_TRACK_ORDER
} from "./actionTypes";
export function play() {
@@ -247,3 +256,21 @@ export function removeSelectedTracks() {
});
};
}
+
+export function reverseList() {
+ return { type: REVERSE_LIST };
+}
+
+export function randomizeList() {
+ return { type: RANDOMIZE_LIST };
+}
+
+export function sortListByTitle() {
+ return (dispatch, getState) => {
+ const state = getState();
+ const trackOrder = sort(state.playlist.trackOrder, i =>
+ state.tracks[i].title.toLowerCase()
+ );
+ return dispatch({ type: SET_TRACK_ORDER, trackOrder });
+ };
+}
diff --git a/js/actionTypes.js b/js/actionTypes.js
index af48a6b5..b83e01e5 100644
--- a/js/actionTypes.js
+++ b/js/actionTypes.js
@@ -52,3 +52,6 @@ export const CROP_TRACKS = "CROP_TRACKS";
export const FILE_INFO = "FILE_INFO";
export const REMOVE_TRACKS = "REMOVE_TRACKS";
export const SET_AVALIABLE_SKINS = "SET_AVALIABLE_SKINS";
+export const REVERSE_LIST = "REVERSE_LIST";
+export const RANDOMIZE_LIST = "RANDOMIZE_LIST";
+export const SET_TRACK_ORDER = "SET_TRACK_ORDER";
diff --git a/js/components/PlaylistWindow/MiscMenu.js b/js/components/PlaylistWindow/MiscMenu.js
index b1a0621d..3f11ccd4 100644
--- a/js/components/PlaylistWindow/MiscMenu.js
+++ b/js/components/PlaylistWindow/MiscMenu.js
@@ -1,17 +1,35 @@
import React from "react";
import { connect } from "react-redux";
-import { FILE_INFO } from "../../actionTypes";
+import {
+ reverseList,
+ randomizeList,
+ sortListByTitle
+} from "../../actionCreators";
import PlaylistMenu from "./PlaylistMenu";
+import { ContextMenu, Hr, Node } from "../ContextMenu";
/* eslint-disable no-alert */
+/* TODO: This should really be kitty-corner to the upper right hand corner of the MiscMenu */
+const SortContextMenu = props => (
+