tools/kvm_stat: sort '-f help' output

Sort the fields returned by specifying '-f help' on the command line.
While at it, simplify the code a bit, indent the output and eliminate an
extra blank line at the beginning.

Signed-off-by: Stefan Raspl <raspl@linux.vnet.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by Stefan Raspl and committed by Paolo Bonzini aa12f594 fae1a3e7

+6 -10
+6 -10
tools/kvm/kvm_stat/kvm_stat
··· 1579 1579 1580 1580 stats = Stats(options) 1581 1581 1582 - if options.fields == "help": 1582 + if options.fields == 'help': 1583 1583 stats.fields_filter = None 1584 - event_list = "\n" 1585 - s = stats.get() 1586 - for key in s.keys(): 1587 - if key.find('(') != -1: 1588 - key = key[0:key.find('(')] 1589 - if event_list.find('\n' + key + '\n') == -1: 1590 - event_list += key + '\n' 1591 - sys.stdout.write(event_list) 1592 - return "" 1584 + event_list = [] 1585 + for key in stats.get().keys(): 1586 + event_list.append(key.split('(', 1)[0]) 1587 + sys.stdout.write(' ' + '\n '.join(sorted(set(event_list))) + '\n') 1588 + sys.exit(0) 1593 1589 1594 1590 if options.log: 1595 1591 log(stats)