I have table with strings like this:
abc-1.2.3-1
abc-1.2.11-3
abc-1.11.3-2
abc-1.2.11-21
abcd-12345-7
abcd-12345-21
abc-def-1-3
Now, what I know for sure that there is a name (I don't know the length, it can be 1 character as well as it can be 15 characters and it can contain hyphens itself) then hyphen character and then version number.
As you have probably noticed, "version numbers" have different structures, one looks like 12345-7
and in next line there can be 1.2.3-3
(basically, I know this is a number with optional dots beetwen digits (1.2.3
part) which ends with hyphen and a number (e.g. -23
).
If I simply sort it, then I have something like this:
abc-1.11.3-2
abc-1.2.11-21
abc-1.2.11-3
abc-1.2.3-1
abcd-12345-21
abcd-12345-7
abc-def-1-3
What I'd like would be:
abc-1.2.3-1
abc-1.2.11-3
abc-1.2.11-21
abc-1.11.3-2
abcd-12345-7
abcd-12345-21
abc-def-1-3
Sort it alphabetically, but whenever you find a number, treat it like a number.
I've seen a solutions with using functions LEN/MID/RIGHT and similar, but don't know how to apply them to my case.