function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Matt Eck 15Matt Eck 15 

JS .sort not working in Lighting Web Component

Hey all,
I am currently trying out Lighting Web Components and have been stuck on the same issue for a while now. I have a Wrapper class (progWrap) with a list of another Wrapper class (progList) as one of it's attributes. I want to sort that list using an attribute from the wapper class making up progList.

To do so I want to use JS .sort and my current sort method looks like this:
let sortList = this.progWrap.progList.slice();
        console.log(JSON.stringify(sortList));
        sortList.sort(function(a,b){
            if(a.programCountry < b.programCountry){
                return -1;
            }
            if(a.programCountry > b.programCountry){
                return 1;
            }
            return 0
        });
        console.log(JSON.stringify(sortList));
I know this sort is working correctly because I checked it using the console.logs.
All I want to do is assign this.progWrap.progList = sortList; but everytime I do I get this error:

['set' on proxy: trap returned falsish for property 'progList']

What does this mean, and how can I prevent this?
 
Matt Eck 15Matt Eck 15
I should clarify, I am using the track decorator and have '@track progWrap' listed at the top of the JS file.
I am also calling the sort function from a button click.