<commit_before>import React from 'react'
import update from 'react-addons-update'
import d3 from 'd3'
import D3Chart from '../../utils/D3Chart'

import {queryResultNester, nestedQueryResultLabelizer} from '../../../lib/queryResultNester'
import {benchmarkColor, benchmarkHighLightColor} from '../../../data/colorPalette'
import {CHARTS} from '../../../config/chartTypes'

function sortData(data, direction) {
  const sortedRows = data.rows.slice().sort((rowA, rowB) => {
    const varA = rowA.tabellvariabel
    const varB = rowB.tabellvariabel
    return direction == 'ascending' ? (varA - varB) : (varB - varA)
  })
  return update(data, {
    rows: {$set: sortedRows}
  })
}

export default class BenchmarkChart extends React.Component {
  /* eslint-disable react/forbid-prop-types */
  static propTypes = {
    data: React.PropTypes.object,
    className: React.PropTypes.string,
    sortDirection: React.PropTypes.string
  }
  /* eslint-enable react/forbid-prop-types */

  prepareData(data) {
    const dimensionLabels = data.dimensions
    const preparedData = nestedQueryResultLabelizer(queryResultNester(data.rows, dimensionLabels), dimensionLabels)<commit_msg>Correctly sort values in benchmarkchart<commit_after>import React from 'react'
import update from 'react-addons-update'
import d3 from 'd3'
import D3Chart from '../../utils/D3Chart'

import {queryResultNester, nestedQueryResultLabelizer} from '../../../lib/queryResultNester'
import {benchmarkColor, benchmarkHighLightColor} from '../../../data/colorPalette'
import {CHARTS} from '../../../config/chartTypes'

function sortData(data, direction) {
  const sortedRows = data.rows.slice().sort((rowA, rowB) => {
    const varA = rowA.value
    const varB = rowB.value
    return direction == 'ascending' ? (varA - varB) : (varB - varA)
  })
  return update(data, {
    rows: {$set: sortedRows}
  })
}

export default class BenchmarkChart extends React.Component {
  /* eslint-disable react/forbid-prop-types */
  static propTypes = {
    data: React.PropTypes.object,
    className: React.PropTypes.string,
    sortDirection: React.PropTypes.string
  }
  /* eslint-enable react/forbid-prop-types */

  prepareData(data) {
    const dimensionLabels = data.dimensions
    const preparedData = nestedQueryResultLabelizer(queryResultNester(data.rows, dimensionLabels), dimensionLabels)
{'fraction_non_alphanumeric': 0.13202725724020442, 'fraction_numerical': 0.0034071550255536627, 'mean_word_length': 4.008528784648187, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1207019', 'n_tokens_mistral': 713, 'n_tokens_neox': 711, 'n_words': 167}