From 87e4a3da43e7d203d3405f977ce8e93298dd55c3 Mon Sep 17 00:00:00 2001 From: Rory Dudley Date: Thu, 11 Apr 2024 21:49:51 -0600 Subject: Sort output of 'export' and 'alias' Sort the output of the built-in 'export' and 'alias' commands, in cases where all environment variables/aliases are printed out. --- src/poem/anthology/alias.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/poem/anthology/alias.rs') diff --git a/src/poem/anthology/alias.rs b/src/poem/anthology/alias.rs index 248342e..511bd3a 100644 --- a/src/poem/anthology/alias.rs +++ b/src/poem/anthology/alias.rs @@ -1,4 +1,5 @@ use crate::poem::Verse; +use std::collections::BTreeMap; use std::collections::HashMap; /// alias @@ -23,7 +24,8 @@ pub fn incant(verse: &Verse, out: &mut Vec, aliases: &mut HashMap { let mut lines = Vec::new(); - for (key, val) in aliases { + let sorted: BTreeMap<_, _> = aliases.into_iter().collect(); + for (key, val) in sorted { let line = if key.contains(' ') && val.contains(' ') { format!("'{}'='{}'", key, val) } else if key.contains(' ') { -- cgit v1.2.3