js小程序 数组sort排序

3358关注11198浏览

pxcs:function(){

        var that = this;

        var arr = new Array();

        arr = [["中猫猫er", "E7555大号", "包背带", "150", "0.16"], ["卜要见、卜要贱", "CA0913大", "包背垫", "333", "0.18"]];

        arr.sort(function (x, y) {

        return x[1].localeCompare(y[1]);

        });

        

        that.setData({

        arr:arr

        })

        console.log(this.data.arr);

        console.log(that.data.arr)

},

pxcs2: function () {

        var that = this;

        console.log(this.data.arr)

        console.log(that.data.arr);

        var an_arr = that.data.arr

        

        //以下这个排序为什么 会影响that.data.arr

        an_arr.sort(function (x, y) {

        return x[3].localeCompare(y[3]);

        });

},


展开全部
收起
1回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • Aubrey

    1人对此回答表示赞同

    对象赋值是相当于传地址,赋值后是同一个地址。

    展开
    1
    1回复
    发布于 5年前

    评论(1)

    收起评论

    • Matthew 2019-01-22 15:28

      感谢帮助,解决了我的问题。

      回复
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部