index.js
function filterResults(results, maximum) {
  var filteredResults = []
  var indices = []
  var matrix = {}
  var column
  var key
  var score
  var interpolated
  var index
  var otherIndex
  var maxScore

  for (key in results) {
    score = results[key].score

    if (!matrix[score]) {
      matrix[score] = []
      indices.push(score)
    }

    matrix[score].push(results[key])
  }

  indices.sort(reverse)

  maxScore = indices[0]

  index = -1

  while (indices[++index]) {
    score = indices[index]
    column = matrix[score]

    interpolated = score / maxScore
    otherIndex = -1

    while (column[++otherIndex]) {
      column[otherIndex].score = interpolated
    }

    filteredResults = filteredResults.concat(column)

    if (filteredResults.length >= maximum) {
      break
    }
  }

  return filteredResults
}
function filterResults(results, maximum) {
  var filteredResults = []
  var indices = []
  var matrix = {}
  var column
  var key
  var score
  var interpolated
  var index
  var otherIndex
  var maxScore

  for (key in results) {
    score = results[key].score

    if (!matrix[score]) {
      matrix[score] = []
      indices.push(score)
    }

    matrix[score].push(results[key])
  }

  indices.sort(reverse)

  maxScore = indices[0]

  index = -1

  while (indices[++index]) {
    score = indices[index]
    column = matrix[score]

    interpolated = score / maxScore
    otherIndex = -1

    while (column[++otherIndex]) {
      column[otherIndex].score = interpolated
    }

    filteredResults = filteredResults.concat(column)

    if (filteredResults.length >= maximum) {
      break
    }
  }

  return filteredResults
}
function filterResults ( results , maximum ) { var filteredResults = [ ] var indices = [ ] var matrix = { } var column var key var score var interpolated var index var otherIndex var maxScore for ( key in results ) { score = results [ key ] . score if ( ! matrix [ score ] ) { matrix [ score ] = [ ] indices . push ( score ) } matrix [ score ] . push ( results [ key ] ) } indices . sort ( reverse ) maxScore = indices [ 0 ] index = - 1 while ( indices [ ++ index ] ) { score = indices [ index ] column = matrix [ score ] interpolated = score / maxScore otherIndex = - 1 while ( column [ ++ otherIndex ] ) { column [ otherIndex ] . score = interpolated } filteredResults = filteredResults . concat ( column ) if ( filteredResults . length >= maximum ) { break } } return filteredResults }
Get the top results from an occurance map.
Get the top results from an occurance map .