亲测,代码如下:

 var str = '中华人民共和国民主富强';
var arr = str.split("");//字符串装换数组方法一
//arr = str.replace(/(.)(?=[^$])/g,"$1,").split(",");字符串转换数组方法二
console.log(arr);
arr.sort(function(a,b){return a.localeCompare(b)});//按拼音排序
console.log(arr)

javaScript将string转换成array,并将汉字按汉语拼音排序方法的更多相关文章

  1. 调用短信接口,先var_dump()看数据类型是object需要json_decode(json_encode( $resp),true)转换成array

    返回的数据.先看类型,如果是object类型 先json_encode, 再json_decode,加true 转换成数组 $resp = $c->execute($req); var_dump ...

  2. PHP实现INT型,SHORT型,STRING转换成BYTE数组

    实现PHP实现INT型,SHORT型,STRING转换成BYTE数组的转化: class Bytes { public static function integerToBytes($val) { $ ...

  3. 在C#中将String转换成Enum:

    一:  在C#中将String转换成Enum: object Enum.Parse(System.Type enumType, string value, bool ignoreCase); 所以,我 ...

  4. C# 字符串string类型转换成DateTime类型 或者 string转换成DateTime?(字符串转换成可空日期类型)

    在c#中,string类型转换成DateTime类型是经常用到的,作为基本的知识,这里在此做个小结.一般来说可以使用多种方法进行转换,最常用的就是使用Convert.ToDateTime(string ...

  5. string转换成color转

    string转换成color             string col = "#FF8400";            this.BackColor = System.Draw ...

  6. C# 中怎么将string转换成int型

    int intA = 0;1.intA =int.Parse(str);2.int.TryParse(str, out intA);3.intA = Convert.ToInt32(str);以上都可 ...

  7. AS3中String转换成Boolean

    AS3中, 对布尔值的转换, 规定所有的非空字符串都是true. 下面都不行: var f:Boolean = new Boolean(str); var f:Boolean = str as Boo ...

  8. C#中将表示颜色的string转换成Color

    场景 在Winform中需要存储某控件的Color属性,存储的是string字符串, 然后再对控件进行赋值时需要将string转换成Color. 实现 myPane.YAxis.Color = Sys ...

  9. fastjson在将Map<Integer, String>转换成JSON字符串时,出现中文乱码问题

    fastjson在将Map<Integer, String>转换成JSON字符串时,出现中文乱码问题. 先记下这个坑,改天在看看是怎么导致的,暂时通过避免使用Integer作为键(使用St ...

随机推荐

  1. Jquery学习总结(5)——jQuery选择器

    1. #id : 根据给定的ID匹配一个元素 <p id="myId">这是第一个p标签</p> <p id="not">这 ...

  2. 阻止a标签跳页,使用单击事件函数处理该请求

    阻止a标签跳页href="javascript:void(0)" 单击该标签时 页面不跳页   使用单击事件函数来处理该单击请求  返回上一层页面 ---------------- ...

  3. [Node.js] Proxy Requests for Local and Remote Service Parity

    High availability apps require that no distinction be made between local and remote services. Attach ...

  4. 用PHP去实现静态化

    我们在PHP站点开发过程中为了站点的推广或者SEO的须要,须要对站点进行一定的静态化,这里设计到什么是静态页面,所谓的静态页面.并非页面中没有动画等元素,而是指网页的代码都在页面中,即不须要再去执行P ...

  5. SqlCommand.DeriveParameters failed

    错误信息例如以下: SqlCommand.DeriveParameters failed because the SqlCommand.CommandText property value is an ...

  6. ScrollView+RadioGroup

    今天要分享一下关于动态添加RadioButton的东西: 要实现的效果就是,这个控件可以左右滑动,里面的按钮都是互斥的,类似RadioButton,我的第一反应就是用ScrollView+RadioG ...

  7. Codeforces Round #234 (Div. 2) A. Inna and Choose Options

    A. Inna and Choose Options time limit per test 1 second memory limit per test 256 megabytes input st ...

  8. This Activity already has an action bar supplied by the window decor

    问题描写叙述:继承自AppCompatActivity,使用Toolbar替代ActionBar的时候.出现错误 错误信息: 2.Caused by: java.lang.IllegalStateEx ...

  9. html与JacaScript中的重要思想:预留后路、向后兼容、js分离

    以一个简单的web程序为例 详细设计模式请配合代码及凝视食用 <!DOCTYPE html> <!-- 1 预留退路:假设用户禁用了js.链接还能正常显示吗?(href) 2 分离j ...

  10. LeetCode——Valid Parentheses

    Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...