diff --git a/src/src/app/components/dashboard/dashboard.component.ts b/src/src/app/components/dashboard/dashboard.component.ts index ab139d4..d4884f3 100644 --- a/src/src/app/components/dashboard/dashboard.component.ts +++ b/src/src/app/components/dashboard/dashboard.component.ts @@ -233,7 +233,9 @@ export class DashboardComponent implements OnInit, AfterViewInit { p.description?.toLowerCase().includes(searchValue), ); - this.visiblePlaces.sort((a, b) => a.name.localeCompare(b.name)); + this.visiblePlaces.sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, + ); } resetFilters() { @@ -326,7 +328,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { .subscribe({ next: (place: Place) => { this.places = [...this.places, place].sort((a, b) => - a.name.localeCompare(b.name), + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, ); setTimeout(() => { this.updateMarkersAndClusters(); @@ -372,7 +374,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { .pipe(take(1)) .subscribe((places) => { this.places = [...this.places, ...places].sort((a, b) => - a.name.localeCompare(b.name), + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, ); setTimeout(() => { this.updateMarkersAndClusters(); @@ -528,7 +530,9 @@ export class DashboardComponent implements OnInit, AfterViewInit { const places = [...this.places]; const idx = places.findIndex((p) => p.id == place.id); if (idx > -1) places.splice(idx, 1, place); - places.sort((a, b) => a.name.localeCompare(b.name)); + places.sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, + ); this.places = places; this.selectedPlace = { ...place }; setTimeout(() => { @@ -631,7 +635,7 @@ export class DashboardComponent implements OnInit, AfterViewInit { .subscribe({ next: (resp) => { this.places = [...this.places, ...resp.places].sort((a, b) => - a.name.localeCompare(b.name), + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, ); this.categories = resp.categories; @@ -766,8 +770,8 @@ export class DashboardComponent implements OnInit, AfterViewInit { .subscribe({ next: (category: Category) => { this.categories.push(category); - this.categories.sort((categoryA: Category, categoryB: Category) => - categoryA.name.localeCompare(categoryB.name), + this.categories.sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, ); this.activeCategories.add(category.name); }, @@ -812,9 +816,8 @@ export class DashboardComponent implements OnInit, AfterViewInit { } sortCategories() { - this.categories = [...this.categories].sort( - (categoryA: Category, categoryB: Category) => - categoryA.name.localeCompare(categoryB.name), + this.categories = [...this.categories].sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, ); } diff --git a/src/src/app/components/shared-trip/shared-trip.component.ts b/src/src/app/components/shared-trip/shared-trip.component.ts index a8ab52a..fdd4374 100644 --- a/src/src/app/components/shared-trip/shared-trip.component.ts +++ b/src/src/app/components/shared-trip/shared-trip.component.ts @@ -247,7 +247,9 @@ export class SharedTripComponent implements AfterViewInit { } sortTripDays() { - this.trip?.days.sort((a, b) => a.label.localeCompare(b.label)); + this.trip?.days.sort((a, b) => + a.label < b.label ? -1 : a.label > b.label ? 1 : 0, + ); } toggleFiltering() { @@ -309,7 +311,7 @@ export class SharedTripComponent implements AfterViewInit { item.comment?.toLowerCase().includes(searchValue) : true, ) - .sort((a, b) => a.time.localeCompare(b.time)) + .sort((a, b) => (a.time < b.time ? -1 : a.time > b.time ? 1 : 0)) .map((item) => ({ td_id: day.id, td_label: day.label, @@ -337,7 +339,7 @@ export class SharedTripComponent implements AfterViewInit { setPlacesAndMarkers() { this.computePlacesUsedInTable(); this.places = [...(this.trip?.places ?? [])].sort((a, b) => - a.name.localeCompare(b.name), + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, ); this.markerClusterGroup?.clearLayers(); this.places.forEach((p) => { @@ -471,7 +473,7 @@ export class SharedTripComponent implements AfterViewInit { const items = this.trip.days .flatMap((day, idx) => day.items - .sort((a, b) => a.time.localeCompare(b.time)) + .sort((a, b) => (a.time < b.time ? -1 : a.time > b.time ? 1 : 0)) .map((item) => { let data = { text: item.text, @@ -588,7 +590,7 @@ export class SharedTripComponent implements AfterViewInit { const idx = this.trip?.days.findIndex((d) => d.id === day_id); if (!this.trip || idx === undefined || idx == -1) return; const data = this.trip.days[idx].items.sort((a, b) => - a.time.localeCompare(b.time), + a.time < b.time ? -1 : a.time > b.time ? 1 : 0, ); const items = data .map((item) => { @@ -709,7 +711,11 @@ export class SharedTripComponent implements AfterViewInit { ? a.packed ? 1 : -1 - : a.text.localeCompare(b.text), + : a.text < b.text + ? -1 + : a.text > b.text + ? 1 + : 0, ); this.dispPackingList = sorted.reduce>( diff --git a/src/src/app/components/trips/trips.component.ts b/src/src/app/components/trips/trips.component.ts index c24632e..376dd31 100644 --- a/src/src/app/components/trips/trips.component.ts +++ b/src/src/app/components/trips/trips.component.ts @@ -110,7 +110,7 @@ export class TripsComponent implements OnInit { return Number(!!a.archived) - Number(!!b.archived); } - return a.name.localeCompare(b.name); + return a.name < b.name ? -1 : a.name > b.name ? 1 : 0; }); } diff --git a/src/src/app/modals/trip-place-select-modal/trip-place-select-modal.component.ts b/src/src/app/modals/trip-place-select-modal/trip-place-select-modal.component.ts index f3e09ec..b7c1299 100644 --- a/src/src/app/modals/trip-place-select-modal/trip-place-select-modal.component.ts +++ b/src/src/app/modals/trip-place-select-modal/trip-place-select-modal.component.ts @@ -38,7 +38,9 @@ export class TripPlaceSelectModalComponent { ) { this.apiService.getPlaces().subscribe({ next: (places) => { - this.places = places.sort((a, b) => a.name.localeCompare(b.name)); + this.places = places.sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, + ); this.displayedPlaces = places; }, }); @@ -78,7 +80,9 @@ export class TripPlaceSelectModalComponent { this.selectedPlacesID.push(p.id); this.selectedPlaces.push(p); - this.selectedPlaces.sort((a, b) => a.name.localeCompare(b.name)); + this.selectedPlaces.sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, + ); } closeDialog() { diff --git a/src/src/app/services/api.service.ts b/src/src/app/services/api.service.ts index 2c3d7e5..63767c3 100644 --- a/src/src/app/services/api.service.ts +++ b/src/src/app/services/api.service.ts @@ -41,8 +41,8 @@ export class ApiService { _categoriesSubjectNext(categories: Category[]) { this.categoriesSubject.next( - [...categories].sort((categoryA: Category, categoryB: Category) => - categoryA.name.localeCompare(categoryB.name), + [...categories].sort((a, b) => + a.name < b.name ? -1 : a.name > b.name ? 1 : 0, ), ); }