Sorting an Array of GameObjects by Name

How can I sort an array of gameObjects by name in Javascript. I’ve looked at a few examples but they are concerning an array of values, not gameObjects. The names will have a number at the end which they will be sorted by in numerical order. (1, 2, 3, ect.) How can this be done?

You can find the solution here

If the starting string in the names are the same, like gameobject1, gameobject2, strip that with Substring(10), and compare the digital part only. If you have more than ten remember to use gameobject09 instead of gameobject9, because - say - 10 goes before 9 in alphabetical order.

You can also parse the digital part to int and sort numerically

or if the numbers are sequential just loop through the gameobjects

YourArray[int.TryParse (gameObject.name.Substring(10))] = gameObject