Skip to content

Instantly share code, notes, and snippets.

@jmhbrown
Created September 4, 2015 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmhbrown/04a2e292e9ae973f9991 to your computer and use it in GitHub Desktop.
Save jmhbrown/04a2e292e9ae973f9991 to your computer and use it in GitHub Desktop.
reorder based on fqdn
# Reorders an array based on a node's FQDN
#
# @param [String] fqdn server's fully qualified domain name
# @param [Array] array An array that needs reordering
# @returns [Array] A reordered copy of the provided array
def reorder_based_on_fqdn(fqdn, array)
rng = Random.new(Digest::MD5.hexdigest(fqdn).hex)
array.shuffle(random: rng)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment