     # Compares a to b with respect to the query given by the user
     # Uses in order absolute, token, prefix and lexicographical sorting
     fuzzy_sort = (query, a, b) ->
-      abs_result = absolute_sort.call(@, query, a, b)
-      return abs_result   if abs_result
-
-      token_result = token_sort.call(@, query, a, b)
-      return token_result if token_result
-
-      prefix_result = prefix_sort.call(@, query, a, b)
-      return prefix_result if prefix_result
+      @sort_criteria_res ||= @_createSortingREs(query)
+
+      for re in @sort_criteria_res
+        regexp_result = regexp_sort.call(@, re, a, b)
+        return regexp_result if regexp_result
 
       lexicographical_sort(a, b)
 

        re = new RegExp "#{value[0]}|#{value[1]}", 'ig'
        query = query.replace re, "(?:#{value[0]}|#{value[1]})"

      return query

    _createQueryRE: (query, type = 'infix')->
      return new RegExp "#{query}", 'ig'        if type == 'infix'
      return new RegExp "^#{query}", 'ig'       if type == 'prefix'
      return new RegExp "\\b#{query}\\b", 'ig'  if type == 'token'
      return new RegExp "^#{query}$", 'ig'      if type == 'absolute'

    ## REFACTOR THOSE
    ## MAYBE REMOVE THOSE??

      for id, name of @_data
        results.push({id: id, name: name}) if match_func(re, name)

      results = results.sort ((a, b) -> sort_func(query, a, b))
      results.slice 0, @config.maxResultsNum

    _getRemoteData: (query, options)->
