def sorted_by(by = nil)
      if block_given?
        categories.sort { |a, b| yield(b[1]) <=> yield(a[1]) }
      else
        categories.sort { |a, b| send(by, b[0]) <=> send(by, a[0]) }
      end
    end
def sorted_by(by = nil)
      if block_given?
        categories.sort { |a, b| yield(b[1]) <=> yield(a[1]) }
      else
        categories.sort { |a, b| send(by, b[0]) <=> send(by, a[0]) }
      end
    end
Return categories sorted by a given key.
 <tt>by</tt> The key to sort on. This parameter can be omitted if a sorting block is provided instead