From f11fa99d303d3658dfe5a6093dc98ea66832e997 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Tue, 15 Feb 2022 15:08:11 -0600 Subject: [PATCH] check to make sure we have data first (#4484) --- crates/nu-command/src/filters/sort_by.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/nu-command/src/filters/sort_by.rs b/crates/nu-command/src/filters/sort_by.rs index ace5008354..602de86c10 100644 --- a/crates/nu-command/src/filters/sort_by.rs +++ b/crates/nu-command/src/filters/sort_by.rs @@ -138,6 +138,13 @@ pub fn sort( insensitive: bool, config: &Config, ) -> Result<(), ShellError> { + if vec.is_empty() { + return Err(ShellError::LabeledError( + "no values to work with".to_string(), + "no values to work with".to_string(), + )); + } + match &vec[0] { Value::Record { cols,