What I plan to do
I try to sort an array like this...
- 1
- 2
- 2(a)
- 2(b)
- 2(b) #AsimpleName
- 2(b) #NameWithN
- 3
- 4
- 4(a)
- ...
... in Angular2.
My Current Code
Component
this.streetDetailRef = this.afDatabase.list('data/users/' + this.currentUserID + '/territory/' + this.sStreet.parentKey + '/' + this.sStreet.key + '/houseNumbers/');
this.streetDetailData = this.streetDetailRef.snapshotChanges().map(changes => {
return changes.map(c => ({ key: c.payload.key, ...c.payload.val() })).sort();
});
The loop in my view
<ion-item-sliding *ngFor="let house of streetDetailData | async | orderBy: 'number':false" #slidingItem>
<strong>{{ house.number }}</strong> ...
'number' in this case is the clean number without letter. I store the letter in a separate firebase entry. But sure would be possible to store them in the same if needed.
Additional information: I'm using the ngx-orderBy-pipe by VadimDez: https://github.com/VadimDez/ngx-order-pipe
