实现思路: 将带空格分隔的字符串split成数组,利用数组sort()排序方法,在该方法里面用chartCodeAt()方法比对元素间同位置的字符的ASCII码(同一位置字符的ASCII码相同则继续比对下一个字符)
function convert (str) {var matches = str.match(/\d{1,8}/g)
var len = matches.length
str = ''
for (var i = 0 i < len i++) {
str += String.fromCharCode(parseInt(matches[i], 2))
}
return str
}
var s = convert('011000010110001001100011')
alert(s)