1

我正在做升序字符串排序。目前,“Route101”将排在“Route11”之前,因为 10 在 11 之前。但是,由于 11 小于 101,我希望“Route11”在“Route101”之前。

我知道在 iPhone 中,它有类似的东西,基本上是自然排序:

NSSortDescriptor *cityCodeDescriptor = [[NSSortDescriptor alloc] initWithKey:@"name"
ascending:YES selector:@selector(localizedStandardCompare:)]; 

Android或Java中有类似的东西。

谢谢。

4

1 回答 1

1

这就是你想要的:

http://www.java2s.com/Code/Java/Collections-Data-Structure/NaturalOrderComparator.htm

如果您打算使用它,请阅读许可证,或编写您自己的许可证。

于 2012-12-07T19:13:36.747 回答