Skip to content

Commit

Permalink
feat(#20): update orderby pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
danrevah committed Jan 29, 2017
1 parent d64e70c commit a0a810d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/app/pipes/array/order-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ export class OrderByPipe implements PipeTransform {
}

static orderCompare(prop, asc, a, b) {
const first = GeneralHelper.extractDeepPropertyByMapKey(a, prop);
const second = GeneralHelper.extractDeepPropertyByMapKey(b, prop);
const first = GeneralHelper.extractDeepPropertyByMapKey(a, prop),
second = GeneralHelper.extractDeepPropertyByMapKey(b, prop);

if (first === second) {
return 0;
Expand All @@ -60,8 +60,9 @@ export class OrderByPipe implements PipeTransform {
return asc ? pos : -pos;
}

const pos = first < second ? -1 : 1;
return asc ? pos : -pos;
return asc
? first - second
: second - first;
}

static extractFromConfig(config) {
Expand Down

0 comments on commit a0a810d

Please sign in to comment.