VadimDez / ngx-order-pipe

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

Null or undefined values #35

Closed theblomskog closed 6 years ago

theblomskog commented 6 years ago

If target values are null or undefined, sorting becomes corrupt. I have cloned your project and fixed it so it fits my use-case, where some values in rows might be null or undefined. I just implemented a compare function as follows: static compare(a: any, b: any ) { if(a == null && b == null) return 0; if(a != null && b == null) return -1; if(a == null && b != null) return 1 return a > b ? 1 : -1; } And replaced some of the logic. I also created som more tests to verify it. Would you be intressted in me making a pull request?

VadimDez commented 6 years ago

If it makes the project better - sure!

VadimDez commented 6 years ago

Fixed by #44, released in 1.1.3