---
title: CKLocationSortDescriptor
framework: cloudkit
role: symbol
role_heading: Class
path: cloudkit/cklocationsortdescriptor
---

# CKLocationSortDescriptor

An object for sorting records that contain location data.

## Declaration

```swift
class CKLocationSortDescriptor
```

## Overview

Overview You can add a location sort descriptor to your queries when searching for records. At creation time, you must provide the sort descriptor with a key that has a CLLocation object as its value. The sort descriptor uses the value of that key to perform the sort. CloudKit computes distance by drawing a direct line between the two locations that follows the curvature of the Earth. Distances don’t account for altitude changes between the two locations.

## Topics

### Creating a Location Sort Descriptor

- [init(key:relativeLocation:)](cloudkit/cklocationsortdescriptor/init(key:relativelocation:).md)
- [init(coder:)](cloudkit/cklocationsortdescriptor/init(coder:).md)

### Accessing the Location Value

- [relativeLocation](cloudkit/cklocationsortdescriptor/relativelocation.md)

### Initializers

- [init(key:ascending:comparator:)](cloudkit/cklocationsortdescriptor/init(key:ascending:comparator:).md)

## Relationships

### Inherits From

- [NSSortDescriptor](foundation/nssortdescriptor.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSCoding](foundation/nscoding.md)
- [NSCopying](foundation/nscopying.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)
- [NSSecureCoding](foundation/nssecurecoding.md)
- [Sendable](swift/sendable.md)
- [SendableMetatype](swift/sendablemetatype.md)

## See Also

### Queries

- [CKQuery](cloudkit/ckquery.md)
- [CKQueryOperation](cloudkit/ckqueryoperation.md)
