<commit_before>define (require) ->
  d3 = require 'd3'
  Signals = require 'Signal'

  class SelectionManager
    constructor: (@tweenTime) ->
      @selection = []
      @onSelect = new Signals.Signal()

    removeDuplicates: () =>
      result = []
      for item in @selection
        found = false
        for item2 in result
          if item.isEqualNode(item2)
            console.log item
            found = true
            break
        if found == false then result.push(item)

      @selection = result

    reset: () =>
      @selection = []
      @highlightItems()
      @onSelect.dispatch(@selection, false)

    select: (item, addToSelection = false) ->
      if !addToSelection then @selection = []
      if item instanceof Array
        for el in item
          @selection.push(el)
      else
        @selection.push(item)

      @removeDuplicates()
      @highlightItems()
      @onSelect.dispatch(@selection, addToSelection)<commit_msg>sort keys in editor, partially fix #3<commit_after>define (require) ->
  d3 = require 'd3'
  Signals = require 'Signal'
  Utils = require 'cs!core/Utils'

  class SelectionManager
    constructor: (@tweenTime) ->
      @selection = []
      @onSelect = new Signals.Signal()

    removeDuplicates: () =>
      result = []
      for item in @selection
        found = false
        for item2 in result
          if item.isEqualNode(item2)
            found = true
            break
        if found == false then result.push(item)

      @selection = result

    sortSelection: () =>
      compare = (a, b) ->
        if !a.__data__ || !b.__data__ then return 0
        if a.__data__.time < b.__data__.time then return -1
        if a.__data__.time > b.__data__.time then return 1
        return 0
      @selection = @selection.sort(compare)

    reset: () =>
      @selection = []
      @highlightItems()
      @onSelect.dispatch(@selection, false)

    select: (item, addToSelection = false) ->
      if !addToSelection then @selection = []
      if item instanceof Array
        for el in item
          @selection.push(el)
      else
        @selection.push(item)

      @removeDuplicates()
      @highlightItems()
      @sortSelection()
      @onSelect.dispatch(@selection, addToSelection)
{'fraction_non_alphanumeric': 0.10809608540925267, 'fraction_numerical': 0.005782918149466192, 'mean_word_length': 2.106353591160221, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 16, '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': '7475999', 'n_tokens_mistral': 647, 'n_tokens_neox': 624, 'n_words': 173}