you would have to do something like this:

objArray.sort(function(a, b) {
    var textA = a.DepartmentName.toUpperCase();
    var textB = b.DepartmentName.toUpperCase();
    return (textA < textB) ? -1 : (textA > textB) ? 1 : 0;
});

note: changing the case (to upper or lower) ensures a case insensitive sort.

Answer from Omer Bokhari on Stack Overflow
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › object › sort array of objects
Sort an array of objects in JavaScript - 30 seconds of code
January 15, 2024 - This allows us to quickly check the order of a value. After that, we use Array.prototype.sort() and compare the values of the property based on our order object.
Discussions

JavaScript Array of Objects Sorting: How to Sort by a Specific Object Property
I have an array of objects in JavaScript, and I want to sort them based on a specific property of the objects. For example, I have an array of books, and each book object has properties like 'title', 'author', and 'publicationYear'. How can I sort this array of book objects alphabetically by the ... More on community.esri.com
🌐 community.esri.com
September 18, 2023
javascript - Sort objects in an array alphabetically based on one property - Stack Overflow
I know that there is a similar question, Javascript - sort objects in an array alphabetically on one property of the array, but when I run step by step using this method it jumps over the sort. I ... More on stackoverflow.com
🌐 stackoverflow.com
January 5, 2018
How do I sort an object alphabetically?

Object keys have a traversal order. Integer keys are always first, and are sorted in an ascending order, whereas with non-integer keys, the order of assignment is preserved. However, this means that sorting will only work on non integer keys, because they are always 1st, and always sorted in an ascending order.

With non-numeric keys like this, you could sort it using entries:

const customers = {
	"_1": "Joe Shmo",
	"_2": "Carrot Top",
	"_3": "Nicolas Cage"
};
const customersArr = Object.entries(customers);
let sorted = customersArr.sort((a, b) => a[1].localeCompare(b[1]));
sorted = Object.fromEntries(sorted);

But, this is really the wrong data-type if you want consistent and easy sorting. Use an array of objects like this and the sorting is much easier.

const customers = [
	{
		id: 1,
		name: "Joe Shmo"
	},
	{
		id: 2,
		name: "Carrot Top"
	},
	{
		id: 3,
		name: "Nicolas Cage"
	}
];
const sorted = customers.sort((a, b) => a.name.localeCompare(b.name));
More on reddit.com
🌐 r/learnjavascript
8
7
September 21, 2019
How to sort an array of objects by 3 properties?
You're only handling the letter cases in your comparison function. You also need to handle string and counts (when not equal). Right now its returning the implicit undefined More on reddit.com
🌐 r/learnjavascript
15
1
January 31, 2017
🌐
Flavio Copes
flaviocopes.com › home › javascript › sort an array of objects by a property in javascript
Sort an array of objects by a property in JavaScript
September 20, 2026 - To sort an array of objects by ... properties. For example you want to order it by the color name, in alphabetical order: black, red, white....
🌐
LabEx
labex.io › tutorials › javascript-sort-array-alphabetically-28618
Sort Array Alphabetically in JavaScript | LabEx
You can call the alphabetical function with an array of objects and the getter function that returns the property to sort by.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-sort-alphabetically-in-javascript
Sort Alphabetically in JavaScript – How to Order by Name in JS
November 7, 2024 - Looking at the object above, the previous method in which we just applied the sort() method on the array directly will not work. Instead, it will throw the same array but the items won't be in the order we want.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-sort-an-array-of-objects-by-property-values
How to sort an array of objects by property values ? - GeeksforGeeks
July 23, 2025 - Pick any property and sort the object on the basis of that property's values in other objects inside an array of objects. There are several methods that can be used to sort an array of objects by property values
🌐
Reactgo
reactgo.com › javascript-sort-objects-alphabetically
How to sort an array of Objects alphabetically in JavaScript | Reactgo
March 29, 2023 - Now we need to sort the objects in an above array alphabetically by using its name property. JavaScript has a built-in sort() method which helps us to sort an array alphabetically.
Find elsewhere
🌐
Esri Community
community.esri.com › home › developers › arcgis maps sdk for javascript
JavaScript Array of Objects Sorting: How to Sort by a Specific Object Property - Esri Community
September 18, 2023 - I have an array of objects in JavaScript, and I want to sort them based on a specific property of the objects. For example, I have an array of books, and each book object has properties like 'title', 'author', and 'publicationYear'. How can I sort this array of book objects alphabetically by the ...
🌐
Codemzy
codemzy.com › blog › how-to-sort-array-objects-javascript
How to sort an array of objects in JavaScript - Codemzy's Blog
May 22, 2023 - You can sort any array of objects in JavaScript using the `sort()` method and giving it a compare function with the property value you want to sort by. Here's how it works with examples.
🌐
Vultr Docs
docs.vultr.com › javascript › examples › sort array of objects by property values
JavaScript Program to Sort Array of Objects by Property ...
December 18, 2024 - The youngest person comes last in this sorted array. Utilize the localeCompare() method in your comparator function to sort objects by a string property. ... const products = [ { name: "Keyboard", price: 30 }, { name: "Mouse", price: 20 }, { ...
🌐
DEV Community
dev.to › fpaghar › donesort-an-array-of-objects-ways-in-javascript-48hl
Sort an Array of Objects Ways in JavaScript - DEV Community
March 24, 2024 - This function alphabetical accepts an array arr, a getter function to extract the property for comparison, and an optional order parameter to specify the sorting direction. By default, it sorts in ascending order ('asc'), but it can be overridden ...
🌐
JavaScript Kit
javascriptkit.com › javatutors › arraysort2.shtml
Sorting an array of objects
JavaScript Kit, accessible through javascriptkit.com, is a long-running educational website focused on client-side web development, especially JavaScript, HTML, and CSS. Its importance lies less in innovation and more in continuity. The site has existed across several distinct phases of the ...
🌐
YouTube
youtube.com › watch
Array Sort JS - Javascript Sort Alphabetically and Sort Array of Objects Javascript - YouTube
Check out Filestack - https://www.filestack.com/?utm_source=MonsterlessonsAcademy&utm_medium=Leads Acquisition&utm_content=MonsterlessonsAcademy-YT-0330202...
Published: May 3, 2022
🌐
CoreUI
coreui.io › blog › how-to-sort-an-array-of-objects-by-string-property-value-in-javascript
How to sort an array of objects by string property value in JavaScript · CoreUI
January 18, 2025 - Sorting an array of objects by string property value in JavaScript is straightforward with the sort method and a custom comparison function.
🌐
Our Code World
ourcodeworld.com › articles › read › 764 › how-to-sort-alphabetically-an-array-of-objects-by-key-in-javascript
How to sort alphabetically an array of objects by key in JavaScript | Our Code World
June 23, 2018 - Finally, to sort an array of objects, simply call the sort method of the array and pass as first argument the dynamicSort function that expects as well as first argument a string, namely the key of the object that you want to sort.
🌐
Scaler
scaler.com › home › topics › sort array alphabetically in javascript
Sort Array Alphabetically in JavaScript - Scaler Topics
May 4, 2023 - When you have a list of words, you might occasionally want to alphabetize each term (from a-z). Alternatively, you might wish to sort people according to their names and have an array of objects with user information, such as names. The sorting methods in javascript mean the swapping of the position of the elements of an array based on some criteria. These criteria are defined by the user.
🌐
SitePoint
sitepoint.com › blog › javascript › quick tip: how to sort an array of objects in javascript
Sort an Array of Objects in JavaScript with the sort() method— SitePoint
November 7, 2024 - To sort an array of objects by a specific key (property) in JavaScript, you can use the Array.prototype.sort() method along with a custom comparison function that compares the values of the desired key for each object.