0
var currStatus = '';
var job = [...this.state.data];
return <div>
    {
        job.length ?
            <div>
                {
                    Object.keys(job).forEach(jobTree) => {
                        job[jobTree].sortBy((leftItem, rightItem) => {
                            return leftItem.job.Title.localeCompare(rightItem.job.Title)
                        });

                        <div><h2>{jobTree}</h2></div>
                        this.state.data[jobTree].forEach((row) => {
                            if(currStatus != row.status.Title) {
                                currStatus = row.status.Title;
                                <div> <h3>{currStatus}</h3></div>
                            }
                        });
                    })

I used sort() to sort job alphabetically.

But I am getting an error:

Uncaught (in promise) TypeError: Job[jobTree].sort is not a function

1 Answer 1

0

The sort() method in Typescript/Javascript is used to sorts an array alphabetically.

So, make sure you are calling this method on Array variable.

  1. TypeScript - Array sort()
  2. JavaScript Sorting Arrays

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.