根据age属性进行排序: const arr1 = [33, 11, 55, 22, 66]; const arr2 = [{age: 55}, {age: 22}, {age: 11}, {age: 66}, {age: 33}] // 排序 arr2 arr2.sort((prev, next) => arr1.indexOf(prev.…
vue中根据城市的首字母a-z进行排序 先安装 js-pinyin 依赖: npm i --save js-pinyin 然后在组件中引入: import pyjs from 'js-pinyin' export default { async mounted() { let city = [ { name: '北京' }, { name: '上海…
var arr = [6,8,1,5,7,0,9] function bubbleSort(arr){ var len = arr.length; for (var i = 0; i < len; i++){ …