如何排序整数字符串? [英] How to Sort Integer Strings?
本文介绍了如何排序整数字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我面临着一个奇怪的问题,同时整理与整数值的字符串列表。然而,一些值可能是pfixed一些字符$ P $。
I am facing a strange problem while sorting a list of strings with integer values. However some values could be prefixed with some characters.
例如。
// B1, 5, 50, A10, 7, 72, B3, A1, A2
基本上有页码,并应当加以分类,如:
There are basically page numbers and should be sorted like:
// A1, A2, A10, B1, B3, 5, 7, 50, 72
但是,如果我用默认的字符串排序,那么这些将被分拣像
But if I use default string sorting then these will be sorted like
// A1, A10, A2, B1, B3, 5, 50, 7, 72
这在C#中的任何解决方案?
Any solution for this in C#?
推荐答案
您正在寻找的 Alphanum算法一> 。幸运的是,一个许多实施已经存在。请参阅 这里
You're looking for the Alphanum algorithm. Fortunately for you, a number of implementations exist already. See here.
这篇关于如何排序整数字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文