Method: Pod::YAMLHelper.sorted_array

Defined in:
lib/cocoapods-core/yaml_helper.rb

.sorted_array(array) ⇒ Array

TODO:

This stuff is here only because the Lockfile intermixes strings and hashes for the ‘PODS` key. The Lockfile should be more consistent.

Note:

If the value contained in the array is another Array or a Hash the first value of the collection is used for sorting, as this method is more useful, for arrays which contains a collection composed by one object.

Sorts an array according to the string representation of it values. This method allows to sort arrays which contains strings or hashes.

Returns:

  • (Array)

    The sorted array.


256
257
258
259
260
# File 'lib/cocoapods-core/yaml_helper.rb', line 256

def sorted_array(array)
  array.each_with_index.sort_by do |element, index|
    [sorting_string(element), index]
  end.map(&:first)
end