<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Combine",
  "identifier" : "/documentation/Combine/Publishers/TryComparison",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "Combine"
    ],
    "preciseIdentifier" : "s:7Combine10PublishersO13TryComparisonV"
  },
  "title" : "Publishers.TryComparison"
}
-->

# Publishers.TryComparison

A publisher that republishes items from another publisher only if each new item is in increasing order from the previously-published item, and fails if the ordering logic throws an error.

```
struct TryComparison<Upstream> where Upstream : Publisher
```

## Topics

### Creating a try-comparison publisher

[`init(upstream: Upstream, areInIncreasingOrder: (Upstream.Output, Upstream.Output) throws -> Bool)`](/documentation/Combine/Publishers/TryComparison/init(upstream:areInIncreasingOrder:))

Creates a publisher that republishes items from another publisher only if each new item is in increasing order from the previously-published item, and fails if the ordering logic throws an error.

### Declaring supporting types

[`typealias Output`](/documentation/Combine/Publishers/TryComparison/Output)

The kind of values published by this publisher.

[`typealias Failure`](/documentation/Combine/Publishers/TryComparison/Failure)

The kind of errors this publisher might publish.

### Inspecting publisher properties

[`let upstream: Upstream`](/documentation/Combine/Publishers/TryComparison/upstream)

The publisher from which this publisher receives its elements.

[`let areInIncreasingOrder: (Upstream.Output, Upstream.Output) throws -> Bool`](/documentation/Combine/Publishers/TryComparison/areInIncreasingOrder)

A closure that receives two elements and returns true if they are in increasing order.

## Relationships

### Conforms To

[`Publisher`](/documentation/Combine/Publisher)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)