带数值排序字符串列表

编程入门 行业动态 更新时间:2024-10-27 08:24:47
本文介绍了带数值排序字符串列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有串的名单,这是最有可能的,但不能保证包含数字组成的列表,即

I have a list of string, which is most likely, but not guaranteed to contain a list of numerics, i.e.,

{"1", "6", "2", "21", "89"}

什么是排序的字符串列表,以便它总是会出现按升序排列的方式?

What is the way to sort the string list so that it will always appear in ascending order?

我无法解析字符串做简单排序前第一个数字因为字符串的可以包含非数字字符。我不想去通过列表并检查铸每个组件数字和进行排序。是否有已经存在在那里用于此目的的图书馆吗?

I can't parse the string to numeric first before doing the sorting simply because the string can contain non numeric characters. And I don't want to go through the list and check-cast each component to numerics and do the sorting. Is there already a library existing out there for this purpose?

在我们拥有混合数字和非数字的字符串项,数字串始终优先的情况下在非数字的。

推荐答案

这已经问略有不同,但相同的答案仍然适用,

This has been asked before slightly differently, but the same answer still applies, as they have a C# implementation on the same site.

SO问题一个字符串 - 即,可能-包含一个数字>排序上的绳子可能包含一些通过在

SO Question: Sort on a string that may contain a number

答= stackoverflow/users/1310/scarcher2\">ScArcher2 :的Alphanum算法

Answer provided by ScArcher2: The Alphanum Algorithm

更多推荐

带数值排序字符串列表

本文发布于:2023-10-18 03:26:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1502943.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   数值   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!