     # these two items.
     sortAlphabetically a, b
 
+sortBowerComponents = (config, a, b) ->
+  aLevel = config.bowerMapping[a]
+  bLevel = config.bowerMapping[b]
+  if aLevel? and not bLevel?
+    -1
+  else if not aLevel? and bLevel?
+    1
+  else if aLevel? and bLevel?
+    bLevel - aLevel
+  else
+    sortByVendor config, a, b
+
 # Items wasn't found in config.before, try to find then in
 # config.after.
 # Item that config.after contains would have lower sorting index.

    indexOfA - indexOfB
  else
    sortByAfter config, a, b

sortBowerComponents = (config, a, b) ->
  aLevel = config.bowerMapping[a]
  bLevel = config.bowerMapping[b]
  if aLevel? and not bLevel?
    -1
  else if not aLevel? and bLevel?
    1
  else if aLevel? and bLevel?
    bLevel - aLevel
  else
    sortByBefore config, a, b

# Sorts by pattern.
#

  else if hasA and hasB
    indexOfA - indexOfB
  else
    sortBowerComponents config, a, b

# Try to find items in config.before.
# Item that config.after contains would have bigger sorting index.
