On Tue, Dec 17, 2024 at 08:01:01PM -0800, John Ralls wrote: > I’d made an error when I wrote bit in the bundler script that derives the > version to pass to the setup-generator: It gets the release instal > directories, sorts them, and grabs the last one. The problem with that is > that it’s a lexical sort so if say 5.8, 5.9. and 5.10 directories exist then > the sort order is > Gnucash-5.10 > Gnucash-5.8 > Gnucash-5.9 > And the last one is 5.9. > https://github.com/Gnucash/gnucash-on-windows/commit/317b10b7d99a4ae8281e866efc4403b9b7624320 > changes it to sort them by creation date. That’s still not perfect, of > course, because someone might come along and builds an earlier version by > hand it will have the last time stamp.
I asked the Lord God AI (as I'm not a powershell user) and it came up with this: --- 8<--- # Define an array of strings with non-version related text before the version numbers $versionStrings = @( 'ProductA v1.2.3', 'ProductB v1.10.0', 'ProductC v1.3.5', 'ProductD v2.0.0' ) # Extract the version part using a regular expression and sort by the extracted version $sortedVersions = $versionStrings | Sort-Object { if ($_ -match 'v([\d\.]+)$') { [version]$matches[1] } } # Display the sorted versions $sortedVersions --- 8<--- Don't know how right it is but if it's not right in and of itself then, maybe, it's right enough to get you most of the way there. :) AP _______________________________________________ gnucash-user mailing list gnucash-user@gnucash.org To update your subscription preferences or to unsubscribe: https://lists.gnucash.org/mailman/listinfo/gnucash-user ----- Please remember to CC this list on all your replies. You can do this by using Reply-To-List or Reply-All.