<commit_before>import { createSelector } from 'reselect';
import { sortByKey } from 'utils/data';
import uniq from 'lodash/uniq';
import concat from 'lodash/concat';
import isEmpty from 'lodash/isEmpty';
import camelCase from 'lodash/camelCase';
import sortBy from 'lodash/sortBy';

import indicators from 'data/indicators.json';
import thresholds from 'data/thresholds.json';
import units from 'data/units.json';
import periods from 'data/periods.json';
import extentYears from 'data/extent-years.json';
import types from 'data/types.json';
import weeks from 'data/weeks.json';

import * as WIDGETS from 'components/widgets/manifest';

// get list data
const getCountryData = state => state.countryData || null;
const getCategory = state => state.category || null;
const getLocation = state => state.payload || null;
const getIndicatorWhitelist = state => state.indicatorWhitelist || null;

const options = {
  indicators,
  thresholds,
  units,
  periods,
  extentYears,
  types,
  weeks
};

export const getAdminLevel = createSelector([getLocation], location => {
  if (location.subRegion) return 'subRegion';
  if (location.region) return 'region';
  return 'country';
});

export const getAdminKey = createSelector([getLocation], location => {
  if (location.subRegion) return 'subRegions';
  if (location.region) return 'regions';
  return 'countries';
});

export const getLocationOptions = createSelector(
  [getAdminLevel, getCountryData],
  (admin, countryData) =>
    countryData[admin === 'country' ? 'regions' : 'subRegions']
);

export const getOptions = () => {
  const optionsMeta = {};
  Object.keys(options).forEach(oKey => {
    optionsMeta[oKey] = sortByKey(options[oKey], 'label');
  });
  return optionsMeta;
};

// get lists selected
export const getAdminSelected = createSelector(
  [getAdminLevel, getAdminKey, getCountryData, getLocation],
  (adminLevel, adminKey, locations, location) => {
    const current = locations[adminKey].find(
      i => i.value === location[adminLevel]
    );
    return {
      ...current,
      adminKey,
      adminLevel
    };
  }
);
<commit_msg>sort ordering<commit_after>import { createSelector } from 'reselect';
import { sortByKey } from 'utils/data';
import uniq from 'lodash/uniq';
import concat from 'lodash/concat';
import isEmpty from 'lodash/isEmpty';
import camelCase from 'lodash/camelCase';
import sortBy from 'lodash/sortBy';

import indicators from 'data/indicators.json';
import thresholds from 'data/thresholds.json';
import units from 'data/units.json';
import periods from 'data/periods.json';
import extentYears from 'data/extent-years.json';
import types from 'data/types.json';
import weeks from 'data/weeks.json';

import * as WIDGETS from 'components/widgets/manifest';

// get list data
const getCountryData = state => state.countryData || null;
const getCategory = state => state.category || null;
const getLocation = state => state.payload || null;
const getIndicatorWhitelist = state => state.indicatorWhitelist || null;

const options = {
  indicators,
  thresholds,
  units,
  periods,
  extentYears,
  types,
  weeks
};

export const getAdminLevel = createSelector([getLocation], location => {
  if (location.subRegion) return 'subRegion';
  if (location.region) return 'region';
  return 'country';
});

export const getAdminKey = createSelector([getLocation], location => {
  if (location.subRegion) return 'subRegions';
  if (location.region) return 'regions';
  return 'countries';
});

export const getLocationOptions = createSelector(
  [getAdminLevel, getCountryData],
  (admin, countryData) =>
    countryData[admin === 'country' ? 'regions' : 'subRegions']
);

export const getOptions = () => {
  const optionsMeta = {};
  Object.keys(options).forEach(oKey => {
    optionsMeta[oKey] =
      oKey !== 'weeks' ? sortByKey(options[oKey], 'label') : options[oKey];
  });
  return optionsMeta;
};

// get lists selected
export const getAdminSelected = createSelector(
  [getAdminLevel, getAdminKey, getCountryData, getLocation],
  (adminLevel, adminKey, locations, location) => {
    const current = locations[adminKey].find(
      i => i.value === location[adminLevel]
    );
    return {
      ...current,
      adminKey,
      adminLevel
    };
  }
);

{'fraction_non_alphanumeric': 0.13061896916921628, 'fraction_numerical': 0.0, 'mean_word_length': 4.6068601583113455, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6262776', 'n_tokens_mistral': 1300, 'n_tokens_neox': 1268, 'n_words': 346}