I have an array of objects.
In each object, I'm targeting a property called "myLevel". The values for this property vary in the following string syntax:
[
{myLevel : 'CAT I #4'},
{myLevel : 'CAT I #6'},
{myLevel : 'CAT I #2'},
{myLevel : 'CAT II #15'},
{myLevel : 'CAT III #1'},
{myLevel : 'CAT II #7'},
]
How can I sort the array so that the objects are rearranged in ascending order like so:
[
{myLevel : 'CAT I #2'},
{myLevel : 'CAT I #4'},
{myLevel : 'CAT I #6'},
{myLevel : 'CAT II #7'},
{myLevel : 'CAT II #15'},
{myLevel : 'CAT III #1'}
]
CAT
values with roman numerals go up higher thanIII
? If you need to allow forVIII
being less thanIX
, etc. that complicates things. – nnnnnn Jul 27 at 1:06