From 93c22852aab121fa696cc607efe77ff2da083d47 Mon Sep 17 00:00:00 2001 From: Sean Wheeler Date: Fri, 10 Mar 2023 13:43:40 -0600 Subject: [PATCH] Document the sort order of groups --- .../Group-Object.md | 30 +++++++++++-------- .../Group-Object.md | 25 +++++++++------- .../Group-Object.md | 25 +++++++++------- .../Group-Object.md | 25 +++++++++------- 4 files changed, 62 insertions(+), 43 deletions(-) diff --git a/reference/5.1/Microsoft.PowerShell.Utility/Group-Object.md b/reference/5.1/Microsoft.PowerShell.Utility/Group-Object.md index 1a453549f2ed..6c461b9a30fa 100644 --- a/reference/5.1/Microsoft.PowerShell.Utility/Group-Object.md +++ b/reference/5.1/Microsoft.PowerShell.Utility/Group-Object.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 12/12/2022 +ms.date: 03/10/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/group-object?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 title: Group-Object @@ -345,8 +345,10 @@ Accept wildcard characters: False ### -Property -Specifies the properties for grouping. The objects are arranged into groups based on the value of -the specified property. +Specifies the properties for grouping. The objects are arranged into named groups based on the value +of the specified properties. When no property is specified, objects are grouped by their value or +the `ToString()` representation of their value. The output is sorted in ascending order by the group +names. The value of the **Property** parameter can be a new calculated property. The calculated property can be a script block or a hash table. Valid key-value pairs are: @@ -402,29 +404,31 @@ You can use the **GroupBy** parameter of the formatting cmdlets, such as `Format each property value, the **GroupBy** parameters create a table for each property value with a row for each item that has the property value. -`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET -Framework type. When grouping objects of different .NET Framework types, `Group-Object` uses the -following rules: +`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET type. +When grouping objects of different .NET types, `Group-Object` uses the following rules: - Same Property Names and Types. - If the objects have a property with the specified name, and the property values have the same .NET - Framework type, the property values are grouped the same rules that would be used for - objects of the same type. + If the objects have a property with the specified name, and the property values have the same + .NET type, the property values are grouped by the same rules that would be used for objects + of the same type. - Same Property Names, Different Types. If the objects have a property with the specified name, but the property values have a different - .NET Framework type in different objects, `Group-Object` uses the .NET Framework type of the first - occurrence of the property as the .NET Framework type for that property group. When an object has - a property with a different type, the property value is converted to the type for that group. If - the type conversion fails, the object isn't included in the group. + .NET type in different objects, `Group-Object` uses the .NET type of the first occurrence of the + property as the .NET type for that property group. When an object has a property with a different + type, the property value is converted to the type for that group. If the type conversion fails, + the object isn't included in the group. - Missing Properties. Objects that don't have a specified property can't be grouped. Objects that aren't grouped appear in the final **GroupInfo** object output in a group named `AutomationNull.Value`. +The output is sorted in ascending order by the group names. The items belonging to each group are +not sorted. They are listed in the order in which they were received. + ## RELATED LINKS [about_Calculated_Properties](../Microsoft.PowerShell.Core/About/about_Calculated_Properties.md) diff --git a/reference/7.2/Microsoft.PowerShell.Utility/Group-Object.md b/reference/7.2/Microsoft.PowerShell.Utility/Group-Object.md index b9e250d4990d..1f3d54bae9d7 100644 --- a/reference/7.2/Microsoft.PowerShell.Utility/Group-Object.md +++ b/reference/7.2/Microsoft.PowerShell.Utility/Group-Object.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 12/12/2022 +ms.date: 03/10/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/group-object?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 title: Group-Object @@ -380,8 +380,10 @@ Accept wildcard characters: False ### -Property -Specifies the properties for grouping. The objects are arranged into groups based on the value of -the specified property. +Specifies the properties for grouping. The objects are arranged into named groups based on the value +of the specified properties. When no property is specified, objects are grouped by their value or +the `ToString()` representation of their value. The output is sorted in ascending order by the group +names. The value of the **Property** parameter can be a new calculated property. The calculated property can be a script block or a hash table. Valid key-value pairs are: @@ -438,28 +440,31 @@ You can use the **GroupBy** parameter of the formatting cmdlets, such as `Format each property value, the **GroupBy** parameters create a table for each property value with a row for each item that has the property value. -`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET Core -type. When grouping objects of different .NET Core types, `Group-Object` uses the following rules: +`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET type. +When grouping objects of different .NET types, `Group-Object` uses the following rules: - Same Property Names and Types. If the objects have a property with the specified name, and the property values have the same - .NET Core type, the property values are grouped by the same rules that would be used for objects + .NET type, the property values are grouped by the same rules that would be used for objects of the same type. - Same Property Names, Different Types. If the objects have a property with the specified name, but the property values have a different - .NET Core type in different objects, `Group-Object` uses the .NET Core type of the first - occurrence of the property as the .NET Core type for that property group. When an object has a - property with a different type, the property value is converted to the type for that group. If the - type conversion fails, the object isn't included in the group. + .NET type in different objects, `Group-Object` uses the .NET type of the first occurrence of the + property as the .NET type for that property group. When an object has a property with a different + type, the property value is converted to the type for that group. If the type conversion fails, + the object isn't included in the group. - Missing Properties. Objects that don't have a specified property can't be grouped. Objects that aren't grouped appear in the final **GroupInfo** object output in a group named `AutomationNull.Value`. +The output is sorted in ascending order by the group names. The items belonging to each group are +not sorted. They are listed in the order in which they were received. + ## RELATED LINKS [about_Calculated_Properties](../Microsoft.PowerShell.Core/About/about_Calculated_Properties.md) diff --git a/reference/7.3/Microsoft.PowerShell.Utility/Group-Object.md b/reference/7.3/Microsoft.PowerShell.Utility/Group-Object.md index 3c3801e1da6b..9221fddbee1c 100644 --- a/reference/7.3/Microsoft.PowerShell.Utility/Group-Object.md +++ b/reference/7.3/Microsoft.PowerShell.Utility/Group-Object.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 12/12/2022 +ms.date: 03/10/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/group-object?view=powershell-7.3&WT.mc_id=ps-gethelp schema: 2.0.0 title: Group-Object @@ -380,8 +380,10 @@ Accept wildcard characters: False ### -Property -Specifies the properties for grouping. The objects are arranged into groups based on the value of -the specified property. +Specifies the properties for grouping. The objects are arranged into named groups based on the value +of the specified properties. When no property is specified, objects are grouped by their value or +the `ToString()` representation of their value. The output is sorted in ascending order by the group +names. The value of the **Property** parameter can be a new calculated property. The calculated property can be a script block or a hash table. Valid key-value pairs are: @@ -438,28 +440,31 @@ You can use the **GroupBy** parameter of the formatting cmdlets, such as `Format each property value, the **GroupBy** parameters create a table for each property value with a row for each item that has the property value. -`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET Core -type. When grouping objects of different .NET Core types, `Group-Object` uses the following rules: +`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET type. +When grouping objects of different .NET types, `Group-Object` uses the following rules: - Same Property Names and Types. If the objects have a property with the specified name, and the property values have the same - .NET Core type, the property values are grouped by the same rules that would be used for objects + .NET type, the property values are grouped by the same rules that would be used for objects of the same type. - Same Property Names, Different Types. If the objects have a property with the specified name, but the property values have a different - .NET Core type in different objects, `Group-Object` uses the .NET Core type of the first - occurrence of the property as the .NET Core type for that property group. When an object has a - property with a different type, the property value is converted to the type for that group. If the - type conversion fails, the object isn't included in the group. + .NET type in different objects, `Group-Object` uses the .NET type of the first occurrence of the + property as the .NET type for that property group. When an object has a property with a different + type, the property value is converted to the type for that group. If the type conversion fails, + the object isn't included in the group. - Missing Properties. Objects that don't have a specified property can't be grouped. Objects that aren't grouped appear in the final **GroupInfo** object output in a group named `AutomationNull.Value`. +The output is sorted in ascending order by the group names. The items belonging to each group are +not sorted. They are listed in the order in which they were received. + ## RELATED LINKS [about_Calculated_Properties](../Microsoft.PowerShell.Core/About/about_Calculated_Properties.md) diff --git a/reference/7.4/Microsoft.PowerShell.Utility/Group-Object.md b/reference/7.4/Microsoft.PowerShell.Utility/Group-Object.md index f3095efe69bd..1d0d1d78ece0 100644 --- a/reference/7.4/Microsoft.PowerShell.Utility/Group-Object.md +++ b/reference/7.4/Microsoft.PowerShell.Utility/Group-Object.md @@ -2,7 +2,7 @@ external help file: Microsoft.PowerShell.Commands.Utility.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Utility -ms.date: 12/12/2022 +ms.date: 03/10/2023 online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/group-object?view=powershell-7.4&WT.mc_id=ps-gethelp schema: 2.0.0 title: Group-Object @@ -380,8 +380,10 @@ Accept wildcard characters: False ### -Property -Specifies the properties for grouping. The objects are arranged into groups based on the value of -the specified property. +Specifies the properties for grouping. The objects are arranged into named groups based on the value +of the specified properties. When no property is specified, objects are grouped by their value or +the `ToString()` representation of their value. The output is sorted in ascending order by the group +names. The value of the **Property** parameter can be a new calculated property. The calculated property can be a script block or a hash table. Valid key-value pairs are: @@ -438,28 +440,31 @@ You can use the **GroupBy** parameter of the formatting cmdlets, such as `Format each property value, the **GroupBy** parameters create a table for each property value with a row for each item that has the property value. -`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET Core -type. When grouping objects of different .NET Core types, `Group-Object` uses the following rules: +`Group-Object` doesn't require that the objects being grouped are of the same Microsoft .NET type. +When grouping objects of different .NET types, `Group-Object` uses the following rules: - Same Property Names and Types. If the objects have a property with the specified name, and the property values have the same - .NET Core type, the property values are grouped by the same rules that would be used for objects + .NET type, the property values are grouped by the same rules that would be used for objects of the same type. - Same Property Names, Different Types. If the objects have a property with the specified name, but the property values have a different - .NET Core type in different objects, `Group-Object` uses the .NET Core type of the first - occurrence of the property as the .NET Core type for that property group. When an object has a - property with a different type, the property value is converted to the type for that group. If the - type conversion fails, the object isn't included in the group. + .NET type in different objects, `Group-Object` uses the .NET type of the first occurrence of the + property as the .NET type for that property group. When an object has a property with a different + type, the property value is converted to the type for that group. If the type conversion fails, + the object isn't included in the group. - Missing Properties. Objects that don't have a specified property can't be grouped. Objects that aren't grouped appear in the final **GroupInfo** object output in a group named `AutomationNull.Value`. +The output is sorted in ascending order by the group names. The items belonging to each group are +not sorted. They are listed in the order in which they were received. + ## RELATED LINKS [about_Calculated_Properties](../Microsoft.PowerShell.Core/About/about_Calculated_Properties.md)