Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions middleware/sortResponseData.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const _ = require('lodash');
const stable = require('stable');

const logger = require('pelias-logger').get('api');

Expand All @@ -12,8 +13,8 @@ function setup(comparator, should_execute) {
// capture the pre-sort order
const presort_order = res.data.map(_.property('_id'));

// sort operates on array in place
res.data.sort(comparator(req.clean));
// stable operates on array in place
stable.inplace(res.data, comparator(req.clean));

// capture the post-sort order
const postsort_order = res.data.map(_.property('_id'));
Expand Down