diff --git a/frontend/src/Settings/CustomFormats/CustomFormats/CustomFormatsConnector.js b/frontend/src/Settings/CustomFormats/CustomFormats/CustomFormatsConnector.js
index 8e828620b..0417d9b21 100644
--- a/frontend/src/Settings/CustomFormats/CustomFormats/CustomFormatsConnector.js
+++ b/frontend/src/Settings/CustomFormats/CustomFormats/CustomFormatsConnector.js
@@ -4,12 +4,12 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { cloneCustomFormat, deleteCustomFormat, fetchCustomFormats } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import CustomFormats from './CustomFormats';
function createMapStateToProps() {
return createSelector(
- createSortedSectionSelector('settings.customFormats', sortByName),
+ createSortedSectionSelector('settings.customFormats', sortByProp('name')),
(customFormats) => customFormats
);
}
diff --git a/frontend/src/Settings/DownloadClients/DownloadClients/DownloadClientsConnector.js b/frontend/src/Settings/DownloadClients/DownloadClients/DownloadClientsConnector.js
index d9e543469..0dc410fcb 100644
--- a/frontend/src/Settings/DownloadClients/DownloadClients/DownloadClientsConnector.js
+++ b/frontend/src/Settings/DownloadClients/DownloadClients/DownloadClientsConnector.js
@@ -5,12 +5,12 @@ import { createSelector } from 'reselect';
import { deleteDownloadClient, fetchDownloadClients } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import createTagsSelector from 'Store/Selectors/createTagsSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import DownloadClients from './DownloadClients';
function createMapStateToProps() {
return createSelector(
- createSortedSectionSelector('settings.downloadClients', sortByName),
+ createSortedSectionSelector('settings.downloadClients', sortByProp('name')),
createTagsSelector(),
(downloadClients, tagList) => {
return {
diff --git a/frontend/src/Settings/ImportLists/ImportLists/ImportListsConnector.js b/frontend/src/Settings/ImportLists/ImportLists/ImportListsConnector.js
index 5c6bad8e7..5eb47068d 100644
--- a/frontend/src/Settings/ImportLists/ImportLists/ImportListsConnector.js
+++ b/frontend/src/Settings/ImportLists/ImportLists/ImportListsConnector.js
@@ -4,12 +4,12 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { deleteImportList, fetchImportLists, fetchRootFolders } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import ImportLists from './ImportLists';
function createMapStateToProps() {
return createSelector(
- createSortedSectionSelector('settings.importLists', sortByName),
+ createSortedSectionSelector('settings.importLists', sortByProp('name')),
(importLists) => importLists
);
}
diff --git a/frontend/src/Settings/Indexers/Indexers/IndexersConnector.js b/frontend/src/Settings/Indexers/Indexers/IndexersConnector.js
index cb6e830fd..88c571a60 100644
--- a/frontend/src/Settings/Indexers/Indexers/IndexersConnector.js
+++ b/frontend/src/Settings/Indexers/Indexers/IndexersConnector.js
@@ -5,12 +5,12 @@ import { createSelector } from 'reselect';
import { cloneIndexer, deleteIndexer, fetchIndexers } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import createTagsSelector from 'Store/Selectors/createTagsSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import Indexers from './Indexers';
function createMapStateToProps() {
return createSelector(
- createSortedSectionSelector('settings.indexers', sortByName),
+ createSortedSectionSelector('settings.indexers', sortByProp('name')),
createTagsSelector(),
(indexers, tagList) => {
return {
diff --git a/frontend/src/Settings/Metadata/Metadata/MetadatasConnector.js b/frontend/src/Settings/Metadata/Metadata/MetadatasConnector.js
index fb52ac33b..8675f4742 100644
--- a/frontend/src/Settings/Metadata/Metadata/MetadatasConnector.js
+++ b/frontend/src/Settings/Metadata/Metadata/MetadatasConnector.js
@@ -4,12 +4,12 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { fetchMetadata } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import Metadatas from './Metadatas';
function createMapStateToProps() {
return createSelector(
- createSortedSectionSelector('settings.metadata', sortByName),
+ createSortedSectionSelector('settings.metadata', sortByProp('name')),
(metadata) => metadata
);
}
diff --git a/frontend/src/Settings/Notifications/Notifications/NotificationsConnector.js b/frontend/src/Settings/Notifications/Notifications/NotificationsConnector.js
index b306f742a..6351c6f8a 100644
--- a/frontend/src/Settings/Notifications/Notifications/NotificationsConnector.js
+++ b/frontend/src/Settings/Notifications/Notifications/NotificationsConnector.js
@@ -5,12 +5,12 @@ import { createSelector } from 'reselect';
import { deleteNotification, fetchNotifications } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import createTagsSelector from 'Store/Selectors/createTagsSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import Notifications from './Notifications';
function createMapStateToProps() {
return createSelector(
- createSortedSectionSelector('settings.notifications', sortByName),
+ createSortedSectionSelector('settings.notifications', sortByProp('name')),
createTagsSelector(),
(notifications, tagList) => {
return {
diff --git a/frontend/src/Settings/Profiles/Metadata/MetadataProfiles.js b/frontend/src/Settings/Profiles/Metadata/MetadataProfiles.js
index d39303ecc..5e719517f 100644
--- a/frontend/src/Settings/Profiles/Metadata/MetadataProfiles.js
+++ b/frontend/src/Settings/Profiles/Metadata/MetadataProfiles.js
@@ -5,7 +5,7 @@ import FieldSet from 'Components/FieldSet';
import Icon from 'Components/Icon';
import PageSectionContent from 'Components/Page/PageSectionContent';
import { icons, metadataProfileNames } from 'Helpers/Props';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import translate from 'Utilities/String/translate';
import EditMetadataProfileModalConnector from './EditMetadataProfileModalConnector';
import MetadataProfile from './MetadataProfile';
@@ -59,17 +59,20 @@ class MetadataProfiles extends Component {
>
{
- items.filter((item) => item.name !== metadataProfileNames.NONE).sort(sortByName).map((item) => {
- return (
-
- );
- })
+ items
+ .filter((item) => item.name !== metadataProfileNames.NONE)
+ .sort(sortByProp('name'))
+ .map((item) => {
+ return (
+
+ );
+ })
}
b.name ? 1 : -1;
+
+ return a.name.localeCompare(b.name, undefined, { numeric: true });
}).map((x) => items[x.format]);
}
diff --git a/frontend/src/Settings/Profiles/Quality/QualityProfilesConnector.js b/frontend/src/Settings/Profiles/Quality/QualityProfilesConnector.js
index 581882ffd..4cb318463 100644
--- a/frontend/src/Settings/Profiles/Quality/QualityProfilesConnector.js
+++ b/frontend/src/Settings/Profiles/Quality/QualityProfilesConnector.js
@@ -4,12 +4,12 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { cloneQualityProfile, deleteQualityProfile, fetchQualityProfiles } from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import QualityProfiles from './QualityProfiles';
function createMapStateToProps() {
return createSelector(
- createSortedSectionSelector('settings.qualityProfiles', sortByName),
+ createSortedSectionSelector('settings.qualityProfiles', sortByProp('name')),
(qualityProfiles) => qualityProfiles
);
}
diff --git a/frontend/src/Settings/Tags/AutoTagging/AutoTaggings.js b/frontend/src/Settings/Tags/AutoTagging/AutoTaggings.js
index 0d86721af..005547bb7 100644
--- a/frontend/src/Settings/Tags/AutoTagging/AutoTaggings.js
+++ b/frontend/src/Settings/Tags/AutoTagging/AutoTaggings.js
@@ -13,7 +13,7 @@ import {
} from 'Store/Actions/settingsActions';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
import createTagsSelector from 'Store/Selectors/createTagsSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import translate from 'Utilities/String/translate';
import AutoTagging from './AutoTagging';
import EditAutoTaggingModal from './EditAutoTaggingModal';
@@ -27,7 +27,7 @@ export default function AutoTaggings() {
isFetching,
isPopulated
} = useSelector(
- createSortedSectionSelector('settings.autoTaggings', sortByName)
+ createSortedSectionSelector('settings.autoTaggings', sortByProp('name'))
);
const tagList = useSelector(createTagsSelector());
diff --git a/frontend/src/Store/Actions/artistIndexActions.js b/frontend/src/Store/Actions/artistIndexActions.js
index 72cb20142..055e92662 100644
--- a/frontend/src/Store/Actions/artistIndexActions.js
+++ b/frontend/src/Store/Actions/artistIndexActions.js
@@ -1,6 +1,6 @@
import { createAction } from 'redux-actions';
import { filterBuilderTypes, filterBuilderValueTypes, filterTypePredicates, sortDirections } from 'Helpers/Props';
-import sortByName from 'Utilities/Array/sortByName';
+import sortByProp from 'Utilities/Array/sortByProp';
import translate from 'Utilities/String/translate';
import { filterPredicates, filters, sortPredicates } from './artistActions';
import createHandleActions from './Creators/createHandleActions';
@@ -334,7 +334,7 @@ export const defaultState = {
return acc;
}, []);
- return tagList.sort(sortByName);
+ return tagList.sort(sortByProp('name'));
}
},
{
diff --git a/frontend/src/Store/Selectors/createRootFoldersSelector.ts b/frontend/src/Store/Selectors/createRootFoldersSelector.ts
index a016d7665..ba61e0ec6 100644
--- a/frontend/src/Store/Selectors/createRootFoldersSelector.ts
+++ b/frontend/src/Store/Selectors/createRootFoldersSelector.ts
@@ -1,11 +1,12 @@
import { createSelector } from 'reselect';
import { RootFolderAppState } from 'App/State/SettingsAppState';
import createSortedSectionSelector from 'Store/Selectors/createSortedSectionSelector';
-import sortByName from 'Utilities/Array/sortByName';
+import RootFolder from 'typings/RootFolder';
+import sortByProp from 'Utilities/Array/sortByProp';
export default function createRootFoldersSelector() {
return createSelector(
- createSortedSectionSelector('settings.rootFolders', sortByName),
+ createSortedSectionSelector('rootFolders', sortByProp('name')),
(rootFolders: RootFolderAppState) => rootFolders
);
}
diff --git a/frontend/src/Store/Selectors/createSortedSectionSelector.js b/frontend/src/Store/Selectors/createSortedSectionSelector.ts
similarity index 68%
rename from frontend/src/Store/Selectors/createSortedSectionSelector.js
rename to frontend/src/Store/Selectors/createSortedSectionSelector.ts
index 331d890c9..abee01f75 100644
--- a/frontend/src/Store/Selectors/createSortedSectionSelector.js
+++ b/frontend/src/Store/Selectors/createSortedSectionSelector.ts
@@ -1,14 +1,18 @@
import { createSelector } from 'reselect';
import getSectionState from 'Utilities/State/getSectionState';
-function createSortedSectionSelector(section, comparer) {
+function createSortedSectionSelector(
+ section: string,
+ comparer: (a: T, b: T) => number
+) {
return createSelector(
(state) => state,
(state) => {
const sectionState = getSectionState(state, section, true);
+
return {
...sectionState,
- items: [...sectionState.items].sort(comparer)
+ items: [...sectionState.items].sort(comparer),
};
}
);
diff --git a/frontend/src/System/Tasks/Queued/QueuedTaskRowNameCell.tsx b/frontend/src/System/Tasks/Queued/QueuedTaskRowNameCell.tsx
index 77142c5a3..41a307d5f 100644
--- a/frontend/src/System/Tasks/Queued/QueuedTaskRowNameCell.tsx
+++ b/frontend/src/System/Tasks/Queued/QueuedTaskRowNameCell.tsx
@@ -3,6 +3,7 @@ import { useSelector } from 'react-redux';
import { CommandBody } from 'Commands/Command';
import TableRowCell from 'Components/Table/Cells/TableRowCell';
import createMultiArtistsSelector from 'Store/Selectors/createMultiArtistsSelector';
+import sortByProp from 'Utilities/Array/sortByProp';
import translate from 'Utilities/String/translate';
import styles from './QueuedTaskRowNameCell.css';
@@ -39,9 +40,7 @@ export default function QueuedTaskRowNameCell(
}
const artists = useSelector(createMultiArtistsSelector(movieIds));
- const sortedArtists = artists.sort((a, b) =>
- a.sortName.localeCompare(b.sortName)
- );
+ const sortedArtists = artists.sort(sortByProp('sortName'));
return (
diff --git a/frontend/src/Utilities/Array/sortByName.js b/frontend/src/Utilities/Array/sortByName.js
deleted file mode 100644
index 1956d3bac..000000000
--- a/frontend/src/Utilities/Array/sortByName.js
+++ /dev/null
@@ -1,5 +0,0 @@
-function sortByName(a, b) {
- return a.name.localeCompare(b.name);
-}
-
-export default sortByName;
diff --git a/frontend/src/Utilities/Array/sortByProp.ts b/frontend/src/Utilities/Array/sortByProp.ts
new file mode 100644
index 000000000..8fbde08c9
--- /dev/null
+++ b/frontend/src/Utilities/Array/sortByProp.ts
@@ -0,0 +1,13 @@
+import { StringKey } from 'typings/Helpers/KeysMatching';
+
+export function sortByProp<
+ // eslint-disable-next-line no-use-before-define
+ T extends Record,
+ K extends StringKey
+>(sortKey: K) {
+ return (a: T, b: T) => {
+ return a[sortKey].localeCompare(b[sortKey], undefined, { numeric: true });
+ };
+}
+
+export default sortByProp;
diff --git a/frontend/src/typings/Helpers/KeysMatching.ts b/frontend/src/typings/Helpers/KeysMatching.ts
new file mode 100644
index 000000000..0e20206ef
--- /dev/null
+++ b/frontend/src/typings/Helpers/KeysMatching.ts
@@ -0,0 +1,7 @@
+type KeysMatching = {
+ [K in keyof T]-?: T[K] extends V ? K : never;
+}[keyof T];
+
+export type StringKey = KeysMatching;
+
+export default KeysMatching;
diff --git a/src/NzbDrone.Core/Localization/Core/en.json b/src/NzbDrone.Core/Localization/Core/en.json
index 642d99a2a..4434790a1 100644
--- a/src/NzbDrone.Core/Localization/Core/en.json
+++ b/src/NzbDrone.Core/Localization/Core/en.json
@@ -89,6 +89,7 @@
"AnalyticsEnabledHelpText": "Send anonymous usage and error information to {appName}'s servers. This includes information on your browser, which {appName} WebUI pages you use, error reporting as well as OS and runtime version. We will use this information to prioritize features and bug fixes.",
"AnalyticsEnabledHelpTextWarning": "Requires restart to take effect",
"AnchorTooltip": "This file is already in your library for a release you are currently importing",
+ "Any": "Any",
"AnyReleaseOkHelpText": "{appName} will automatically switch to the release best matching downloaded tracks",
"ApiKeyHelpTextWarning": "Requires restart to take effect",
"ApiKeyValidationHealthCheckMessage": "Please update your API key to be at least {0} characters long. You can do this via settings or the config file",