From de0937f35ac7cd0d1ea929fce41b19d6c86e29eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Moreno?= Date: Wed, 23 Aug 2017 21:04:38 +0200 Subject: [PATCH] Sort rooms by name --- src/app.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index da4a54f2..807b786d 100644 --- a/src/app.rs +++ b/src/app.rs @@ -213,10 +213,17 @@ impl AppOp { let store: gtk::TreeStore = self.gtk_builder.get_object("rooms_tree_store") .expect("Couldn't find rooms_tree_store in ui file."); + let mut array: Vec<(String, String)> = vec![]; for (id, name) in rooms { + array.push((name, id)); + } + + array.sort_by(|x, y| x.0.to_lowercase().cmp(&y.0.to_lowercase())); + + for v in array { store.insert_with_values(None, None, &[0, 1], - &[&name, &id]); + &[&v.0, &v.1]); } }