Skip to content

Commit

Permalink
fix agenda sort issue #327 #328
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkrick committed Oct 5, 2016
1 parent 8618b20 commit 3d2fb6e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/universal/utils/getNextSortOrder.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {SORT_STEP} from './constants';

export default function getNextSortOrder(arr, sortField) {
// we always do a decremental sort
const lastEntity = arr[0];
return lastEntity ? lastEntity[sortField] + SORT_STEP : 0;
const maxVal = Math.max(...arr.map(val => val[sortField]));
// if it is an empty array, maxVal === -Infinity
return Math.max(0, maxVal + SORT_STEP);
}

0 comments on commit 3d2fb6e

Please sign in to comment.