---
title: "apply(index:outputIndices:outputDistances:)"
framework: accelerate
role: symbol
role_heading: Instance Method
path: "accelerate/bnns/nearestneighbors/apply(index:outputindices:outputdistances:)"
---

# apply(index:outputIndices:outputDistances:)

Calculates the sorted indices and Euclidean distances of the k-nearest neighbors to a specified sample data point.

## Declaration

```swift
func apply(index: Int?, outputIndices: BNNSNDArrayDescriptor, outputDistances: BNNSNDArrayDescriptor)
```

## Parameters

- `index`: The index of the sample data point of which the function computes the k-nearest neighbors.
- `outputIndices`: The sorted indices of the k-nearest neighbours to the sample data point.
- `outputDistances`: The sorted distances of the k-nearest neighbours to the sample data point.
