Skip to content

Commit

Permalink
feat(#20): orderBy fully coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
danrevah committed Jan 28, 2017
1 parent d09cacc commit c69f731
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/app/pipes/array/order-by.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class OrderByPipe implements PipeTransform {
const out = [...arr];

if (Array.isArray(config)) {

return out.sort((a, b) => {
let pos;

Expand All @@ -38,7 +37,17 @@ export class OrderByPipe implements PipeTransform {
return out.sort(OrderByPipe.orderCompare.bind(this, prop, asc));
}

return out.sort();
return out.sort((a, b) => {
if (GeneralHelper.isString(a) && GeneralHelper.isString(b)) {
return a.toLowerCase().localeCompare(b.toLowerCase());
}

if (a === b) {
return 0;
}

return a < b ? -1 : 1;
});
}

static orderCompare(prop, asc, a, b) {
Expand Down

0 comments on commit c69f731

Please sign in to comment.