javascript - How to do Natural sorting in angularJs? -


i have object below:

scope.obj=[{option :"option 1" },{option :"option 2" },{option :"option 3" },{option :"option k" }] 

and html

<a ng-repeat="item in obj | orderby :'option':false">{{item.option}}</a> 

and expecting display object list in ascending order below:

option k option 1 option 2 option 3 

but getting output

option 1 option 2 option 3 option k 

i have tried many solution given in stackoverflow , other sites nothing working. pls me solve issue

my expectation if character after "option" string (like option k,option l etc) there should come first in ascending order number should come(option k,option l,option 1,option 2,etc)

the angular documentation says sorts numbers (using natural order) or strings (alphabetically, numbers smaller letters), think should sort array before ng-repeat:

myarray.sort(function mycustomsortfunction(a,b) {...}) 

Comments

Popular posts from this blog

javascript - Complete OpenIDConnect auth when requesting via Ajax -

c# - Replace text in MailItem Body -

java - Get more than One value and display it -