Skip to content

sorted_list == sort(sorted_list) evaluates to false #35407

@adam-rummer-hpe

Description

@adam-rummer-hpe

Terraform Version

Terraform v1.9.0
on darwin_arm64

(also tested with 1.8.2)

Terraform Configuration Files

locals {
  a = ["a", "b", "c"]
}

output "a" {
  value = local.a
}

output "a_sorted" {
  value = sort(local.a)
}

output "sorted" {
  value = local.a == sort(local.a) // evaluates to false
}

Debug Output

https://gist.github.com/adam-rummer-hpe/fb3629195481d99879099950992f36e5

Expected Behavior

when already sorted, the list should be equal to the sorted list

Actual Behavior

they are not evaluated as being equal, despite outputting the same

e.g. a plan produces

Changes to Outputs:
  + a        = [
      + "a",
      + "b",
      + "c",
    ]
  + a_sorted = [
      + "a",
      + "b",
      + "c",
    ]
  + sorted   = false

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.

Steps to Reproduce

  1. terraform init
  2. terraform plan

Additional Context

No response

References

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions