How to sort an array of object values based on string?

Here is a running example of sorting an array object.

https://replit.com/@RA68/creact-react-app#src/App.js

The most important thing is to create your sortOrder.

Here I created an array called sortOrder where I want my objects to be sorted in the order of active, draft and closed.

--

--

--

Software engineer, UX researcher and fashionista in the making!

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What I Learned at Work this Week: JavaScript Prototype

How do you use the .forEach() method in Javascript?

Using Ionic DeepLinker for Webapps

Intro to Recoil

JavaScript Interview Coding Problem — let keyword

How JavaScript works: an overview of the engine, the runtime, and the call stack

How to build a Shopify theme using Vue.js from scratch

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Reshie

Reshie

Software engineer, UX researcher and fashionista in the making!

More from Medium

Bubble Sort

Real Life Example — Recursive Components

Everything you need to know about arrays in JavaScript

7 Must known array functions 🍻 ft.Js