From: Avi Kivity Subject: [PATCH 4/6] kvm_stat: sort tui output according to highest occurence Date: Tue, 31 Aug 2010 16:25:30 +0300 Message-ID: <1283261132-5904-6-git-send-email-avi@redhat.com> References: <1283261132-5904-1-git-send-email-avi@redhat.com> To: Marcelo Tosatti , kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:17421 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756713Ab0HaNZf (ORCPT ); Tue, 31 Aug 2010 09:25:35 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7VDPZGT031281 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 31 Aug 2010 09:25:35 -0400 Received: from cleopatra.tlv.redhat.com (cleopatra.tlv.redhat.com [10.35.255.11]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7VDPY1H029120 for ; Tue, 31 Aug 2010 09:25:34 -0400 In-Reply-To: <1283261132-5904-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: With plenty of counters and wide, short screens it's hard to see what's on the top. So sort the output. Signed-off-by: Avi Kivity --- kvm/kvm_stat | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/kvm/kvm_stat b/kvm/kvm_stat index 677683a..c55bf88 100755 --- a/kvm/kvm_stat +++ b/kvm/kvm_stat @@ -306,7 +306,12 @@ def tui(screen, stats): screen.addstr(0, 0, 'kvm statistics') row = 2 s = stats.get() - for key in sorted(s.keys()): + def sortkey(x): + if s[x][1]: + return -s[x][1] + else: + return x + for key in sorted(s.keys(), key = sortkey): if row >= screen.getmaxyx()[0]: break values = s[key] -- 1.7.1