<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] ### 普通排序(升序a-Z) `.sort()` 方法會遍歷數組,依次比較相鄰的數值,前一位小于后一位返回負數,相等返回0,大于返回正數。該方法會直接更改原數組,不返回數組副本。 ~~~ array.sort((a, b) => a - b) ~~~ ### 中文排序(升序a-Z) >[success] 設置`numeric`屬性為`true`可以對讓數字字符按數值大小排序,而不是按首字符排序,該方法排序完成后順序: 其它字符 - 數字 - 中文 - 英文 ~~~ array.sort((a, b) => a.localeCompare(b, 'zh-Hans-CN', { sensitivity: 'accent', numeric: true })) ~~~ ### 自定義排序順序(升序a-Z) eg: 排序順序為:英文 - 中文 - 數字 - 其它字符 ~~~ array.sort((a, b) => a.localeCompare(b, 'zh-Hans-CN', { sensitivity: 'accent', numeric: true })) const sortResult = handleSortResult(array) handleSortResult(res) { const regStr = /[\u4e00-\u9fa5]/ const regAZ = /[a-z]/i const regN = /[0-9]/ const sortFuction = (index, arr, regs) => { for (let i = index; i < arr.length; i++) { if (regs.test(arr[i].charAt(0))) { return i } } return false } const sortChina = (index, arr) => sortFuction(index, arr, regStr) const sortNumber = (index, arr) => sortFuction(index, arr, regN) const sortEnglish = (index, arr) => sortFuction(index, arr, regAZ) let num = sortNumber(0, res) let cn = sortChina(num || 0, res ) let en = sortEnglish(cn || num || 0, res) en = en === 0 ? 0 : en || res.length cn = cn === 0 ? 0 : cn || en num = num === 0 ? 0 : num || cn // console.error('其它', res.slice(0, num)) // console.error('數字', res.slice(num, cn)) // console.error('中文', res.slice(cn, en)) // console.error('英文', res.slice(en, res.length)) const result = [...res.slice(en, res.length), ...res.slice(cn, en), ...res.slice(num, cn), ...res.slice(0, num)] sortAfter.innerHTML = JSON.stringify(result) } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看