排序数字字符串映射的字符串 [英] Sort number string mapped strings

查看:120
本文介绍了排序数字字符串映射的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在对字符串进行排序时遇到问题.排序在这种情况下不起作用

We have a problem about sorting strings. Sort doesnt work in such case

1-A 1-B 10-A 10-B 9-A 9-B ...

1-A 1-B 10-A 10-B 9-A 9-B ...

我们真正想要的是

1-A 1-B 9-A 9-B 10-A 10-B 如果我们将其排序为字符串,则结果将类似于第一部分.如果我们解析然后进行排序,那么我们如何对其余的A和B进行排序呢?有什么简单的C#解决方案吗?

1-A 1-B 9-A 9-B 10-A 10-B If we sort it as string the result would be like in the first part. If we parse then sort then how can we sort the rest of A's and B's? Is there any simple solution for c#?

谢谢;

推荐答案

您可以使用此比较器实例用于执行排序.

You may implement own comparer where you put your custom comparison logic. Then you may use this comparer instance for performing sorting.

这篇关于排序数字字符串映射的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆