Skip to content

Instantly share code, notes, and snippets.

@hopbit
Created March 17, 2016 01:02
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 hopbit/fed94d0147097d7b667f to your computer and use it in GitHub Desktop.
Save hopbit/fed94d0147097d7b667f to your computer and use it in GitHub Desktop.
ruby map & sort by example
# play it with Sonic Pi v.2.9 (http://sonic-pi.net)
notes = { dd: 74, c: 72, bbbbbbb: 83, ffff: 77, aaaaaa: 81, cccccccc: 84, eee: 76, ggggg: 79 }
notes.keys.map { | key | key.to_sym }.sort_by(&:length).each { |key|
play_pattern [notes[key]]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment