Use stable sort for chain tabs (#113)

This commit is contained in:
Maciej Hirsz
2019-02-21 14:40:56 +01:00
committed by GitHub
parent 76a07654ab
commit ed65a00c95
3 changed files with 13 additions and 6 deletions
+6 -5
View File
@@ -2,6 +2,7 @@ import * as React from 'react';
import { Connection } from '../Connection';
import { Icon } from './Icon';
import { Types, Maybe } from '@dotstats/common';
import stable from 'stable';
import githubIcon from '../icons/mark-github.svg';
import './Chains.css';
@@ -48,11 +49,11 @@ export class Chains extends React.Component<Chains.Props, {}> {
}
private get chains(): ChainData[] {
return Array
.from(this.props.chains.entries())
.sort((a, b) => {
return b[1] - a[1];
})
return stable
.inplace(
Array.from(this.props.chains.entries()),
(a, b) => b[1] - a[1]
)
.map(([label, nodeCount]) => ({ label, nodeCount }));
}