From c69f73180d1091421cbca48a0d986bba5bf9385b Mon Sep 17 00:00:00 2001 From: danrevah Date: Sat, 28 Jan 2017 19:30:19 +0200 Subject: [PATCH] feat(#20): orderBy fully coverage --- src/app/pipes/array/order-by.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/pipes/array/order-by.ts b/src/app/pipes/array/order-by.ts index 539260f7..4a838db5 100644 --- a/src/app/pipes/array/order-by.ts +++ b/src/app/pipes/array/order-by.ts @@ -12,7 +12,6 @@ export class OrderByPipe implements PipeTransform { const out = [...arr]; if (Array.isArray(config)) { - return out.sort((a, b) => { let pos; @@ -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) {