From 2aa2f0de19bf6bac326983302f4e0ec7edf8d6cd Mon Sep 17 00:00:00 2001 From: Egor Yurtaev Date: Sat, 24 Jun 2017 22:09:42 +0600 Subject: [PATCH] Sort files alphanumerically #1185 --- package.json | 1 + src/renderer/pages/torrent-list-page.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/package.json b/package.json index fe5820cc..a9045165 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "material-ui": "^0.17.0", "mkdirp": "^0.5.1", "musicmetadata": "^2.0.2", + "natsort": "^1.0.6", "network-address": "^1.1.0", "parse-torrent": "^5.7.3", "prettier-bytes": "^1.0.1", diff --git a/src/renderer/pages/torrent-list-page.js b/src/renderer/pages/torrent-list-page.js index 18936209..7eaaed2d 100644 --- a/src/renderer/pages/torrent-list-page.js +++ b/src/renderer/pages/torrent-list-page.js @@ -1,5 +1,6 @@ const React = require('react') const prettyBytes = require('prettier-bytes') +const natsort = require('natsort') const Checkbox = require('material-ui/Checkbox').default const LinearProgress = require('material-ui/LinearProgress').default @@ -278,9 +279,11 @@ module.exports = class TorrentList extends React.Component { ) } else { // We do know the files. List them and show download stats for each one + const sorter = natsort() const fileRows = torrentSummary.files .filter((file) => !file.path.includes('/.____padding_file/')) .map((file, index) => ({ file, index })) + .sort((a, b) => sorter(a.file.name, b.file.name)) .map((object) => this.renderFileRow(torrentSummary, object.file, object.index)) filesElement = (