message: Properly memoize character order selector
diff: @@ -2,10 +2,15 @@ import { RootState } from '../store/reducers';
  import { DimStore } from '../inventory/store-types';
  import _ from 'lodash';
  import { DestinyCharacterComponent } from 'bungie-api-ts/destiny2';
  +import { createSelector } from 'reselect';
  -export const characterSortSelector = (state: RootState) => {
  - const order = state.settings.characterOrder;
  +const characterOrderSelector = (state: RootState) => state.settings.characterOrder;
  +const customCharacterSortSelector = (state: RootState) => state.settings.customCharacterSort;
  +export const characterSortSelector = createSelector(
  + characterOrderSelector,
  + customCharacterSortSelector,
  + (order, customCharacterSort) => {
  switch (order) {
  case 'mostRecent':
  return (stores: DimStore[]) => _.sortBy(stores, (store) => store.lastPlayed).reverse();
  @@ -21,7 +26,7 @@ export const characterSortSelector = (state: RootState) => {
  });
  case 'custom': {
  - const customSortOrder = state.settings.customCharacterSort;
  + const customSortOrder = customCharacterSort;
  return (stores: DimStore[]) =>
  _.sortBy(stores, (s) => (s.isVault ? 999 : customSortOrder.indexOf(s.id)));
  }
  @@ -31,11 +36,13 @@ export const characterSortSelector = (state: RootState) => {
  // https://github.com/Bungie-net/api/issues/614
  return (stores: DimStore[]) => _.sortBy(stores, (s) => s.id);
  }
  -};
  -
  -export const characterComponentSortSelector = (state: RootState) => {
  - const order = state.settings.characterOrder;
  + }
  +);
  +export const characterComponentSortSelector = createSelector(
  + characterOrderSelector,
  + customCharacterSortSelector,
  + (order, customCharacterSort) => {
  switch (order) {
  case 'mostRecent':
  return (stores: DestinyCharacterComponent[]) =>
  @@ -48,7 +55,7 @@ export const characterComponentSortSelector = (state: RootState) => {
  });
  case 'custom': {
  - const customSortOrder = state.settings.customCharacterSort;
  + const customSortOrder = customCharacterSort;
  return (stores: DestinyCharacterComponent[]) =>
  _.sortBy(stores, (s) => customSortOrder.indexOf(s.characterId));
  }
  @@ -58,4 +65,5 @@ export const characterComponentSortSelector = (state: RootState) => {
  // https://github.com/Bungie-net/api/issues/614
  return (stores: DestinyCharacterComponent[]) => _.sortBy(stores, (s) => s.characterId);
  }
  -};
  + }
  +);
  