From 0f9186628b4066fcb42ac6af0e2d1a89c50204b7 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Fri, 6 Jul 2018 14:19:49 -0400 Subject: [PATCH] sort orgs --- src/app/settings/organizations.component.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/app/settings/organizations.component.ts b/src/app/settings/organizations.component.ts index 13b950c6fe..d2a2a58a1d 100644 --- a/src/app/settings/organizations.component.ts +++ b/src/app/settings/organizations.component.ts @@ -36,7 +36,22 @@ export class OrganizationsComponent implements OnInit { } async load() { - this.organizations = await this.userService.getAllOrganizations(); + const orgs = await this.userService.getAllOrganizations(); + orgs.sort((a, b) => { + if (a.name == null && b.name != null) { + return -1; + } + if (a.name != null && b.name == null) { + return 1; + } + if (a.name == null && b.name == null) { + return 0; + } + + return this.i18nService.collator ? this.i18nService.collator.compare(a.name, b.name) : + a.name.localeCompare(b.name); + }); + this.organizations = orgs; this.loaded = true; }