VadimDez / ngx-order-pipe

▼ Angular 5+ orderBy pipe
https://vadimdez.github.io/ngx-order-pipe/
MIT License
243 stars 57 forks source link

Sorting data not working properly #69

Closed SrideviYerneni closed 4 years ago

SrideviYerneni commented 6 years ago

Everything works fine except it is not sorting correctly some columns (here in the example, 'Rank' column). How do I need to sort if the data is coming from array like this in example.?

Here's my code:

<table>
                 <thead>
                      <tr>
                        <th (click)="setOrder('name')">Name</th>
                        <th (click)="setOrder('age')">Age</th>
                      <th (click)="setOrder('final_rank')">Rank</th>
                      </tr>
                    </thead>
                    <tbody>
                      <tr *ngFor="let Data of collection | orderBy: order:reverse:'case-insensitive'">
                        <td class="text-truncate">{{Data.name}}</td>
                        <td class="text-truncate">{{Data.age}}</td>

  <td class="text-truncate" *ngIf="!isArray(Data.details)"><tr> {{Data.details.final_rank}} </tr></td>
  <td class="text-truncate" *ngIf="isArray(Data.details)"><tr *ngFor="let rankData of Data.details"> {{rankData.final_rank}} </tr></td>
                      </tr>
                    </tbody>
                  </table>
"collection": [
            {
                "name": "John",
                "age" : "25",
                "details": [
                    {
                        "final_rank": "150"
                    }
                ]
            }
        {
                "name": "Mark",
                "age" : "19",
                "details": [
                    {
                        "final_rank": "254"
                    }
                ]
            }
setOrder(value) {
     if (this.order === value) {
       this.reverse = !this.reverse;
     }
     this.order = value;
     console.log(this.order);
   }
SrideviYerneni commented 6 years ago

@VadimDez Hi. Can you please look into this issue

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.