bitly / data_hacks

Command line utilities for data analysis
http://github.com/bitly/data_hacks
1.94k stars 195 forks source link

Sort by values flag does not work in bar_chart.py #1

Closed kortina closed 14 years ago

kortina commented 14 years ago

Need to modify bar_chart.py as follows:

if options.sort_values:
    data = [[value,key] for key,value in data.items()]
    data.sort(reverse=True)
else:
    # sort by keys
    data = [[key,value] for key,value in data.items()]
    data.sort()
    data = [[value, key] for key,value in data]
format = "%" + str(max_length) + "s [%6d] %s"
for value,key in data:
    print format % (key[:max_length], value, (value / scale) * "*")
kortina commented 14 years ago

I also would love a -r flag, reverse-sort, to set the reverse flag on the .sort() calls

jehiah commented 14 years ago

fix sort commands for bar_charts.py and add a --reverse-sort. closed by 352c13f265e718d728703d9f64151d2ab274585f