Natural sort algorithm implementation woes

一笑奈何 提交于 2019-12-24 04:44:09

问题


I have Googled ASP Classic implementations of the natural sort algorithm to no avail. Best I was able to find was from Dave Koelle, which was from a question on SO. Issue is that since I need to implement this algorithm in ASP Classic, I don't have access to certain functions such as

Collections.sort(your list, new AlphanumComparator());

Ideally, I'd like to pass an array to a function and have it return to me the ordered array.

Any ideas as to what I could do?

Thank you.


回答1:


You haven't specified which language you are using in ASP. Typically this would be VBScript.

However if you were to use JScript instead then you can use JScript's array object and use its sort method. This method optionally takes as a parameter a comparator function.

 var a = new Array();
 // code to populate array

 a.sort(function() { // Comparator code returning (-1|0|1) });

There is no need to convert everything to JScript, you can use utilities written in JScript from VBScript.



来源:https://stackoverflow.com/questions/1278295/natural-sort-algorithm-implementation-woes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!