冒泡排序
原理:相邻的数据进行两两比较,小数放在前面,大数放在后面,这样一趟下来,最小的数就被排在了第一位,第二趟也是如此,如此类推,直到所有的数据排序完成。
实现过程
for(var i=0;i<creditShopList.length-1;i++){//确定轮数
for(var j=0;j<creditShopList.length-i-1;j++){//确定每次比较的次数
if(Number(creditShopList[j].goodInfo.credit)>Number(creditShopList[j+1].goodInfo.credit)){
var tem = creditShopList[j];
creditShopList[j] = creditShopList[j+1];
creditShopList[j+1] = tem;
}
}
}