mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
sort env vars (#544)
This commit is contained in:
parent
a93a9b9029
commit
3ad5d4af66
1 changed files with 11 additions and 2 deletions
|
@ -470,8 +470,17 @@ pub fn eval_variable(
|
|||
let mut output_vals = vec![];
|
||||
|
||||
let env_vars = stack.get_env_vars();
|
||||
let env_columns: Vec<_> = env_vars.keys().map(|x| x.to_string()).collect();
|
||||
let env_values: Vec<_> = env_vars.values().cloned().collect();
|
||||
let env_columns: Vec<String> = env_vars.keys().map(|x| x.to_string()).collect();
|
||||
let env_values: Vec<Value> = env_vars.values().cloned().collect();
|
||||
|
||||
let mut pairs = env_columns
|
||||
.into_iter()
|
||||
.zip(env_values.into_iter())
|
||||
.collect::<Vec<(String, Value)>>();
|
||||
|
||||
pairs.sort_by(|a, b| a.0.cmp(&b.0));
|
||||
|
||||
let (env_columns, env_values) = pairs.into_iter().unzip();
|
||||
|
||||
output_cols.push("env".into());
|
||||
output_vals.push(Value::Record {
|
||||
|
|
Loading…
Reference in a new issue