-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
When running data through Sort-Object -Stable -Unique given a specific property the returned results do not appear to be the 1st element seen from a stable sort. Also modifying modifying the input data for an unrelated record effects the records of another. Below is some sample code that can be used to reproduce the issue. The only difference from the data in the 1st set to the 2nd is the last row was changed from 2021 to 2015 which is effecting the file1 key but the file0 key is consistently showing the last item. The rest of the records appear to process correctly.
$Data="Key,Path,Size
file1,C:\folder\2015,10
file1,C:\folder\2018,10
file1,C:\folder\2020,10
file2,C:\folder\2014,10
file2,C:\folder\2019,10
file4,C:\folder\2020,10
file4,C:\folder\2017,10
file4,C:\folder\2020,10
file4,C:\folder\2019,10
file4,C:\folder\2021,10
file0,C:\folder\2015,10
file0,C:\folder\2018,10
file0,C:\folder\2020,10
file2,C:\folder\2022,10
file3,C:\folder\2019,10
file3,C:\folder\2018,10
file3,C:\folder\2019,10
file3,C:\folder\2020,10
file3,C:\folder\2022,10
file3,C:\folder\2021,10"
$List=$Data | ConvertFrom-Csv
$SortedList=$List | Sort-Object Path -Descending
Write-Host "Sorted List:"
$SortedList | Format-Table
Write-Host "Unique List:"
$SortedList | Sort-Object Key -Unique -Stable | Format-Table
$list[19].Path="C:\folder\2015"
$SortedList=$List | Sort-Object Path -Descending
Write-Host "Sorted List:"
$SortedList | Format-Table
Write-Host "Unique List:"
$SortedList | Sort-Object Key -Unique -Stable | Format-Table```
### Expected behavior
```console
Key Path Size
--- ---- ----
file0 C:\folder\2020 10
file1 C:\folder\2020 10
file2 C:\folder\2022 10
file3 C:\folder\2022 10
file4 C:\folder\2021 10Actual behavior
Case 1:
Key Path Size
--- ---- ----
file0 C:\folder\2015 10
file1 C:\folder\2015 10
file2 C:\folder\2022 10
file3 C:\folder\2022 10
file4 C:\folder\2021 10
Case 2:
Key Path Size
--- ---- ----
file0 C:\folder\2015 10
file1 C:\folder\2020 10
file2 C:\folder\2022 10
file3 C:\folder\2022 10
file4 C:\folder\2021 10Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Name Value
---- -----
PSVersion 7.3.0-preview.1
PSEdition Core
GitCommitId 7.3.0-preview.1
OS Microsoft Windows 10.0.19043
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Metadata
Metadata
Assignees
Labels
Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module