Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
danrevah committed Jan 28, 2017
1 parent 4913332 commit ca5df5d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/app/pipes/array/order-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ export class OrderByPipe implements PipeTransform {

if (Array.isArray(config)) {
return out.sort((a, b) => {
let pos = 0;

for (let i=0, l=config.length; i<l && pos === 0; ++i) {
for (let i=0, l=config.length; i<l; ++i) {
const [prop, asc] = OrderByPipe.extractFromConfig(config[i]);
pos = OrderByPipe.orderCompare(prop, asc, a, b);
const pos = OrderByPipe.orderCompare(prop, asc, a, b);
if (pos !== 0) {
return pos;
}
}

return pos;
return 0;
});
}

Expand All @@ -30,7 +30,7 @@ export class OrderByPipe implements PipeTransform {
if (config.length === 1) {
return asc ? out.sort() : out.sort().reverse();
}

return out.sort(OrderByPipe.orderCompare.bind(this, prop, asc));
}

Expand Down

0 comments on commit ca5df5d

Please sign in to comment.