diff --git a/news/2 Fixes/5414.md b/news/2 Fixes/5414.md new file mode 100644 index 000000000000..ed77d22707b0 --- /dev/null +++ b/news/2 Fixes/5414.md @@ -0,0 +1 @@ +Fix sorting of lists. \ No newline at end of file diff --git a/pythonFiles/datascience/getJupyterVariableDataFrameInfo.py b/pythonFiles/datascience/getJupyterVariableDataFrameInfo.py index 5533e3e94a1b..9a83ec6679e6 100644 --- a/pythonFiles/datascience/getJupyterVariableDataFrameInfo.py +++ b/pythonFiles/datascience/getJupyterVariableDataFrameInfo.py @@ -23,8 +23,9 @@ _VSCODE_columnTypes = [] _VSCODE_columnNames = [] if _VSCODE_targetVariable['type'] == 'list': - _VSCODE_columnTypes = ['string'] # Might be able to be more specific here? - _VSCODE_columnNames = ['_VSCode_JupyterValuesColumn'] + _VSCODE_evalResult = _VSCODE_pd.DataFrame(_VSCODE_evalResult) + _VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes) + _VSCODE_columnNames = list(_VSCODE_evalResult) elif _VSCODE_targetVariable['type'] == 'Series': _VSCODE_evalResult = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult) _VSCODE_columnTypes = list(_VSCODE_evalResult.dtypes) diff --git a/pythonFiles/datascience/getJupyterVariableDataFrameRows.py b/pythonFiles/datascience/getJupyterVariableDataFrameRows.py index ef4cc5402ea1..74fa6974f1c1 100644 --- a/pythonFiles/datascience/getJupyterVariableDataFrameRows.py +++ b/pythonFiles/datascience/getJupyterVariableDataFrameRows.py @@ -16,7 +16,7 @@ # Assume we have a dataframe. If not, turn our eval result into a dataframe _VSCODE_df = _VSCODE_evalResult if (_VSCODE_targetVariable['type'] == 'list'): - _VSCODE_df = _VSCODE_pd.DataFrame({'_VSCode_JupyterValuesColumn':_VSCODE_evalResult}) + _VSCODE_df = _VSCODE_pd.DataFrame(_VSCODE_evalResult) elif (_VSCODE_targetVariable['type'] == 'Series'): _VSCODE_df = _VSCODE_pd.Series.to_frame(_VSCODE_evalResult) elif _VSCODE_targetVariable['type'] == 'dict': diff --git a/src/datascience-ui/data-explorer/mainPanel.tsx b/src/datascience-ui/data-explorer/mainPanel.tsx index ab8a84a8611b..e6f81a1d1a82 100644 --- a/src/datascience-ui/data-explorer/mainPanel.tsx +++ b/src/datascience-ui/data-explorer/mainPanel.tsx @@ -366,8 +366,8 @@ export class MainPanel extends React.Component // or it will take too long const comparer = isStringColumn ? (a: any, b: any): number => { - const aVal = a[sortColumn] as string; - const bVal = b[sortColumn] as string; + const aVal = a[sortColumn].toString(); + const bVal = b[sortColumn].toString(); const aStr = aVal ? aVal.substring(0, Math.min(aVal.length, MaxStringCompare)) : aVal; const bStr = bVal ? bVal.substring(0, Math.min(bVal.length, MaxStringCompare)) : bVal; const result = aStr > bStr ? -1 : 1;