Skip to content

Formatting table with all properties loses original property order #3

Description

@maskati

Formatting table with all properties loses original property order. This is because here all ("*") properties are enumerated using get-member, which does not preserve order.

Example:

$data=@([pscustomobject]@{X=1;Z=2;Y=3},[pscustomobject]@{X=4;Z=5;Y=6},[pscustomobject]@{X=7;Z=8;Y=9})
# format table shows in original order of first instance properties
$data|format-table
# format markdown table uses property alphabetical order
$data|format-markdowntabletablestyle -showmarkdown -hidestandardoutput -donotcopytoclipboard
# this is because the implementation is doing get-member * which is not order preserving
$data[0]|get-member -name @('*') -membertype property,noteproperty
# psobject.properties.name is order preserving
$data[0].psobject.properties.name

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions