I have a column in which i am displaying Email of user, i have added sort functionality to it. But the resultant array is not sorted properly.
Sample code is here
Any help will be appreciated
<ul ng-repeat="user in users | orderBy:'email':false">
In the example code, output of sorting [Ascending] is
But Expected output is
The hint is to use a custom sort function and to "cut" the E-Mail at the @
symbol. Otherwise the whole string is going to be compared and @
is higher in value than +
.
If you only want to match the Usernames
you should be fine. Otherwise you need to also compare the domains, before comparing Usernames
.
Here is a JS Fiddle: http://jsfiddle.net/zjvsu/898/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With