From cc6f064e362492a1e3bfd61af5abb71f89040029 Mon Sep 17 00:00:00 2001 From: Ido Abramovich Date: Tue, 8 Mar 2016 18:16:41 +0200 Subject: [PATCH] sort session by name --- lib/canals/cli/session.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/canals/cli/session.rb b/lib/canals/cli/session.rb index 369cffa..ef72d97 100644 --- a/lib/canals/cli/session.rb +++ b/lib/canals/cli/session.rb @@ -16,7 +16,8 @@ def show require 'terminal-table' require 'canals/core_ext/string' columns = ["up", "pid", "name", "local_port", "socket"] - rows = Canals.session.map{ |s| columns.map{ |c| session_col_val(s, c) } } + rows = Canals.session.sort{ |a,b| a[:name] <=> b[:name] } + .map { |s| columns.map{ |c| session_col_val(s, c) } } table = Terminal::Table.new :headings => columns.map{|c| session_col_title(c) }, :rows => rows table.align_column(3, :right) say table