Created
February 15, 2011 04:45
-
-
Save cchandler/827103 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
histogram = {180=>0, 256=>0, 237=>1, 275=>0, 190=>1, 228=>0, 266=>0, 133=>1, 209=>0, 247=>1, 257=>1, 86=>0, 162=>1, 200=>1, 238=>1, 29=>1, 143=>1, 181=>0, 153=>0, 191=>1, 229=>0, 267=>0, 134=>1, 172=>1, 210=>1, 115=>1, 87=>1, 201=>1, 239=>1, 182=>0, 220=>1, 135=>1, 173=>1, 249=>1, 31=>0, 240=>0, 107=>0, 183=>1, 221=>1, 259=>1, 88=>0, 126=>1, 98=>0, 79=>1, 193=>1, 22=>0, 231=>0, 269=>0, 241=>0, 70=>0, 184=>1, 260=>1, 89=>0, 213=>1, 251=>0, 156=>1, 194=>0, 232=>1, 270=>0, 147=>1, 223=>0, 261=>1, 204=>0, 242=>0, 100=>0, 252=>0, 176=>0, 233=>1, 214=>0, 148=>0, 72=>0, 262=>1, 243=>0, 129=>1, 224=>0, 53=>0, 205=>0, 91=>0, 139=>1, 272=>1, 234=>0, 25=>1, 196=>0, 158=>0, 253=>0, 225=>1, 187=>1, 244=>0, 130=>1, 92=>1, 111=>0, 254=>1, 216=>0, 273=>1, 235=>0, 197=>1, 264=>0, 226=>0, 188=>0, 131=>0, 245=>0, 236=>1, 217=>1, 141=>0, 265=>0, 151=>0, 246=>0, 227=>0, 189=>0, 208=>0, 170=>1} | |
final_histogram = {} | |
histogram.sort(){|a,b| histogram[a[0]] <=> histogram[b[0]] }.map do |i| | |
final_histogram[i[0]] = i[1] | |
end | |
p final_histogram | |
## Relying on Ruby 1.9's insertion order preservation, if using Ruby 1.8 and rails use ActiveSupport::OrderedHash | |
# {180=>0, 256=>0, 208=>0, 275=>0, 189=>0, 228=>0, 266=>0, 227=>0, 209=>0, 246=>0, 151=>0, 86=>0, 265=>0, 141=>0, 245=>0, 131=>0, 188=>0, 181=>0, 153=>0, 226=>0, 229=>0, 267=>0, 264=>0, 235=>0, 216=>0, 111=>0, 244=>0, 253=>0, 158=>0, 182=>0, 196=>0, 234=>0, 91=>0, 205=>0, 31=>0, 240=>0, 107=>0, 53=>0, 224=>0, 243=>0, 88=>0, 72=>0, 98=>0, 148=>0, 214=>0, 22=>0, 231=>0, 269=>0, 241=>0, 70=>0, 176=>0, 252=>0, 89=>0, 100=>0, 251=>0, 242=>0, 194=>0, 204=>0, 270=>0, 223=>0, 156=>1, 261=>1, 232=>1, 147=>1, 213=>1, 260=>1, 184=>1, 233=>1, 193=>1, 79=>1, 126=>1, 262=>1, 259=>1, 129=>1, 221=>1, 183=>1, 249=>1, 173=>1, 139=>1, 272=>1, 135=>1, 25=>1, 220=>1, 239=>1, 201=>1, 225=>1, 187=>1, 87=>1, 130=>1, 92=>1, 115=>1, 254=>1, 210=>1, 273=>1, 172=>1, 197=>1, 134=>1, 191=>1, 143=>1, 29=>1, 238=>1, 236=>1, 217=>1, 200=>1, 162=>1, 257=>1, 247=>1, 133=>1, 190=>1, 237=>1, 170=>1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment