Skip to content

Commit

Permalink
Fix sorting of number only lists (#5416)
Browse files Browse the repository at this point in the history
* Fix sorting problem with number only lists

* Add news entry
  • Loading branch information
rchiodo committed Apr 22, 2019
1 parent 7b1be6f commit d85d97b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions news/2 Fixes/5414.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix sorting of lists.
5 changes: 3 additions & 2 deletions pythonFiles/datascience/getJupyterVariableDataFrameInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pythonFiles/datascience/getJupyterVariableDataFrameRows.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
4 changes: 2 additions & 2 deletions src/datascience-ui/data-explorer/mainPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,8 @@ export class MainPanel extends React.Component<IMainPanelProps, IMainPanelState>
// 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;
Expand Down

0 comments on commit d85d97b

Please sign in to comment.