I am working with an array in Javascript that contains elements with information about free space on different datastores:
myArray = ["Datastore one - free space 34.23GB", "Datastore two - free space 56.23GB",...]
I want to sort this array based on the amount of free space available. For example, in the given array, Datastore two should come first. The structure of each element in the array is always "- free space xx.xxGB", where 'xx' represents the amount of free space which could vary from 1 to 5 digits.
If anyone can guide me on how to sort this array based on free space, I found a regular expression method like this:
"*- free space\s[1-9][0-9]*GB"
So would sorting the array be something like this?
myArray.sort("*- free space\s[1-9][0-9]*GB") ?
Is my approach correct or is there a better way to achieve this? Thank you in advance for your help.