string字母排序,

时间:2022-09-29 16:38:53
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] str = { "student","iphone","abs","ball","wc"};
SortStringArray(str,SortType.rise); for (int i = ; i < str.Length; i++)
{
Console.WriteLine(str[i]);
} Console.ReadKey();
} //按字母排序
static void SortStringArray(string [] array,SortType type)
{
string temp = null; //降序
if (type == SortType.drop)
{
for (int i = ; i < array.Length; i++)
{
for (int j = i; j < array.Length; j++)
{
if ((int)array[i][] < (int)array[j][])
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
}//升序
else if(type == SortType.rise)
{
for (int i = ; i < array.Length; i++)
{
for (int j = i; j < array.Length; j++)
{
if ((int)array[i][] > (int)array[j][])
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
} } public enum SortType
{
drop,
rise
} } }

冒泡算法对string数组排序O(∩_∩)O~

新人求关照,求大家多多指点

string字母排序,的更多相关文章

  1. &lbrack;Android分享&rsqb; 【转帖】Android ListView的A-Z字母排序和过滤搜索功能

      感谢eoe社区的分享   最近看关于Android实现ListView的功能问题,一直都是小伙伴们关心探讨的Android开发问题之一,今天看到有关ListView实现A-Z字母排序和过滤搜索功能 ...

  2. 联系人的侧边字母索引ListView 将手机通讯录姓名通过首字母排序。

      package com.lixu.letterlistview; import java.util.ArrayList; import java.util.List; import org.apa ...

  3. 获取手机通讯录放入PinnedSectionListView中,按名字首字母排序,并且实现拨打电话功能。

    package com.lixu.tongxunlu; import java.util.ArrayList; import com.lixu.tongxunlu.PinnedSectionListV ...

  4. Android 联系人字母排序(仿微信)

    现在很多APP只要涉及到联系人的界面,几乎都会采取字母排序以及导航的方式.作为程序猿,这种已经普及的需求还是需要学习的,于是小生开始了在网上默默的学习之路,网上学习的资料质量参差不齐,不过也有很不错的 ...

  5. HashMap加入数据后,会自动根据首字母排序

    1.Map<String, ArrayList<XX>> entityHashMap = new HashMap<>(); 然后增加一些数据,会发现根据String ...

  6. Android 实现ListView的A-Z字母排序和过滤搜索功能,实现汉字转成拼音

    转载:http://blog.csdn.net/xiaanming/article/details/12684155 转载请注明出处:http://blog.csdn.net/xiaanming/ar ...

  7. 对JSON格式的城市按照拼音首字母排序

    需求说明: App应用中最常见的一种操作就是对城市按照拼音首字母排序,以方便选择城市.而已有的json格式的城市数据是没有这种排序的. 已有的json格式的城市数据格式如下[简化之后]: 数据格式说明 ...

  8. 列表按照字母排序检索SideBar

    项目中要求列表按照ABCD这种字母排序检索的功能,看了大神写的,瞬间崇拜了,接下来借大家参考参考了 首先是自定义view sidebar /** * @author J *一个自定义view 实现a- ...

  9. Android 使用ListView的A-Z字母排序功能实现联系人模块

    在上一篇文章其中,主要学习了ListView的A-Z字母排序功能以及依据输入框的输入值改变来过滤搜索结果,假设输入框里面的值为空.更新为原来的列表,否则为过滤数据列表,包含汉字转成拼音的功能.假设你还 ...

随机推荐

  1. Cannot convert value of type &lbrack;java&period;lang&period;String&rsqb; to required type &lbrack;java&period;util&period;Date&rsqb; for property &&num;39&semi;xxx&&num;39&semi;&colon; no matching editors or conversion strategy found

    今天在完成项目的时候遇到了下面的异常信息: 04-Aug-2014 15:49:27.894 SEVERE [http-apr-8080-exec-5] org.apache.catalina.cor ...

  2. vc 中调用COM组件的方法

    需求:1.创建myCom.dll,该COM只有一个组件,两个接口:   IGetRes--方法Hello(),   IGetResEx--方法HelloEx() 2.在工程中导入组件或类型库  #im ...

  3. 网络拥塞控制与NS2仿真

    准备工作: 1. 安装virtual box 虚拟机,并安装虚拟机增强功能,并配制共享文件夹. 共享文件夹自动挂载后的路径为/media/sf_xxx文件夹,xxx为所起的文件名. 解决virtual ...

  4. SSL&sol;TLS&sol;WTLS原理

    一 前言 首先要澄清一下名字的混淆:1 SSL(Secure Socket Layer)是netscape公司设计的主要用于web的安全传输协议.这种协议在WEB上获得了广泛的应用.2 IETF(ww ...

  5. ubuntu 安装 maven3&period;2

    1.下载并解压 apache-maven-3.2.5-bin.tar.gz tar -xzvf apache-maven--bin.tar.gz 2.设置环境变量 sudo gedit ~/.prof ...

  6. &sol;&sol;&commat;sourceURL&equals;filename&period;js

    在 console 中输入代码的最后一行加上 //@ sourceURL=filename.js, 会在 Scripts 面板中有个叫 filename.js 的文件, 然后他就和外部 js 文件一样 ...

  7. select(Linux 编程)

    select系统调用时用来让我们的程序监视多个文件句柄的状态变化的.程序会停在select这里等待,直到被监视的文件句柄有一个或多个发生了状态改变. 关于文件句柄,其实就是一个整数,通过socket函 ...

  8. JAVA 中转义符的理解

    生物信息中有时候会遇到JAVA写的程序,今天阅读源码的时候发现对于正则中的转义符不好理解,后来查资料后终于弄明白了,这里详细说明一下: 字符串的表示有三种方法:1.直接单字符,例如"A&qu ...

  9. fetch数据请求的封装

    export default class HttpUtils { static get(url){ return new Promise((resolve,reject)=>{ fetch(ur ...

  10. Armstrong公理

    从已知的一些函数依赖,可以推导出另外一些函数依赖,这就需要一系列推理规则,这些规则常被称作“Armstrong 公理”. 设U 是关系模式R 的属性集,F 是R 上成立的只涉及U 中属性的函数依赖集. ...