private void SortInputData() { try { if (string.IsNullOrEmpty(InputData)) { OutputData = string.Empty; return; } if (!InputData.Contains(",")) { if (double.TryParse(InputData, out double output)) { OutputData = output.ToString(); return; } OutputData = string.Empty; return; } var inputData = new List <double>(); foreach (var input in InputData.Split(',').Where(x => !string.IsNullOrEmpty(x))) { if (double.TryParse(input, out double parshedInput)) { inputData.Add(parshedInput); } } var inputArray = inputData.ToArray(); inputArray.MergeSort(); OutputData = string.Join(",", inputArray); } catch (Exception ex) { // this is wrong // we cann't show a dialog from view model // as no logging is implemented so I am adding it here MessageBox.Show(ex.Message, "Error!"); } }