[ad_1]
I have a list of objects $objects
that contains objects like this.
$objects = @(
@{Name="One"; Group = 'A'},
@{Name="Two"; Group = 'B'},
@{Name="Three"; Group = 'B'},
@{Name="Four"; Group = 'A'},
@{Name="Five"; Group = 'C'},
@{Name="Six"; Group = 'B'}
)
I’d like a randomized list of all the objects basing the randomness on Group
property.
So far, I can do this Get-Random -InputObject $objects -Count ([int]::MaxValue)
to get a randomized list. But I don’t know what that is based on.
I was wondering if I can use Group-Object
to group them first by Group
and then start picking from these groups. Hence, the distribution will be based on Group
property.
I can also use Random Class from .Net.
[ad_2]