Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix account sorting issue #41

Merged
merged 1 commit into from
Jun 23, 2024
Merged

Fix account sorting issue #41

merged 1 commit into from
Jun 23, 2024

Conversation

loodakrawa
Copy link
Contributor

The sorting of accounts casts the ID to int which in turn blows up if any of the IDs are not numbers.

Removing the cast fixes the issue.

@shupershuff
Copy link
Owner

Thanks mate, will definitely make this change. FYI as of the latest version you can now use 2 digit ID's if you want.

@shupershuff shupershuff merged commit 40c410b into shupershuff:main Jun 23, 2024
2 checks passed
@shupershuff
Copy link
Owner

I remember why I put [int] at the beginning now. It was because if a user had 2 digit ID's it wasn't organising them properly (eg ID 11 would appear between ID 1 and ID 2). I will replace with this instead, this accommodates 2 digit ID's and character ID's:

foreach ($AccountOption in ($Script:AccountOptionsCSV | Sort-Object -Property @{ #Try sort by number first (needed for 2 digit ID's), then sort by character.
	Expression = {
		# Try to convert the value to an integer
		$intValue = [int]::TryParse($_.ID, [ref]$null)
		# If it's a number, return it as an integer for sorting
		if ($intValue) {
			[int]$_.ID
		}
		# If it's not a number, return a large number to ensure letters come after numbers
		else {
			[char]$_.ID
		}
	}
})){

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants