Fix sorting method

This commit is contained in:
Ildar Kamalov 2018-10-29 15:24:35 +03:00
parent 9173b0ee7a
commit c39831abbc
1 changed files with 1 additions and 16 deletions

View File

@ -23,22 +23,7 @@ class Clients extends Component {
Header: 'IP', Header: 'IP',
accessor: 'ip', accessor: 'ip',
Cell: ({ value }) => (<div className="logs__row logs__row--overflow"><span className="logs__text" title={value}>{value}</span></div>), Cell: ({ value }) => (<div className="logs__row logs__row--overflow"><span className="logs__text" title={value}>{value}</span></div>),
sortMethod: (a, b) => { sortMethod: (a, b) => parseInt(a.replace(/\./g, ''), 10) - parseInt(b.replace(/\./g, ''), 10),
const nextValue = a.split('.');
const prevValue = b.split('.');
for (let i = 0; i < nextValue.length; i += 1) {
const nextNumber = parseInt(nextValue[i], 10);
const prevNumber = parseInt(prevValue[i], 10);
if (nextNumber < prevNumber) {
return -1;
} else if (nextNumber > prevNumber) {
return 1;
}
}
return 0;
},
}, { }, {
Header: 'Requests count', Header: 'Requests count',
accessor: 'count', accessor: 'count',