def sort_by_attr!(objects, order = { locale: :asc, key: :asc })
      order_keys = order.keys
      objects.sort! do |a, b|
        by = order_keys.detect { |k| a[k] != b[k] }
        order[by] == :desc ? b[by] <=> a[by] : a[by] <=> b[by]
      end
      objects
    end
def sort_by_attr!(objects, order = { locale: :asc, key: :asc })
      order_keys = order.keys
      objects.sort! do |a, b|
        by = order_keys.detect { |k| a[k] != b[k] }
        order[by] == :desc ? b[by] <=> a[by] : a[by] <=> b[by]
      end
      objects
    end
Sort keys by their attributes in order
 @param [Hash] order e.g. {locale: :asc, type: :desc, key: :asc}