<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreSpotlight",
  "identifier" : "/documentation/CoreSpotlight/CSSearchableItem/compare(byRank:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Spotlight"
    ],
    "preciseIdentifier" : "c:objc(cs)CSSearchableItem(im)compareByRank:"
  },
  "title" : "compare(byRank:)"
}
-->

# compare(byRank:)

Compares two items by rank and returns the result.

```
func compare(byRank other: CSSearchableItem) -> ComparisonResult
```

## Parameters

`other`

The other item to compare against the current one.

## Return Value

A comparison result that indicates the ranked order of the items.

## Discussion

Call this function when you want to compare the current item with the one you specify. The method compares the ranks of the items.

---

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)