# Angular 5+ Order Pipe
  [](https://travis-ci.org/VadimDez/ngx-order-pipe) [](https://deepscan.io/dashboard/#view=project&pid=1752&bid=7519)
> Order your collection by a field
### Demo page
[https://vadimdez.github.io/ngx-order-pipe/](https://vadimdez.github.io/ngx-order-pipe/)
or see code example
[https://stackblitz.com/edit/ngx-order-pipe](https://stackblitz.com/edit/ngx-order-pipe?embed=1&file=app/app.component.ts)
## Install
```
npm install ngx-order-pipe --save
```
*For Angular lower than 5 use version `1.1.3`*
## Setup
In case you're using `systemjs` - see configuration [here](https://github.com/VadimDez/ngx-order-pipe/blob/master/SYSTEMJS.md). Otherwise skip this part.
## Usage
##### In HTML template
```html
{{ collection | orderBy: expression : reverse : caseInsensitive : comparator }}
```
### Arguments
| Param | Type | Default Value | Details |
| --- | --- | --- | --- |
| collection | `array` or `object` | | The collection or object to sort |
| expression | `string` or `string array` | | The key or collection of keys to determinate order |
| reverse *(optional)* | `boolean`| false | Reverse sorting order |
| caseInsensitive *(optional)* | `boolean`| false | Case insensitive compare for sorting |
| comparator *(optional)* | `Function`| | Custom comparator function to determine order of value pairs. Example: `(a, b) => { return a > b ? 1 : -1; }` [`See how to use comparator`](https://github.com/VadimDez/ngx-order-pipe/issues/39) |
Import `OrderModule` to your module
```typescript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app';
import { OrderModule } from 'ngx-order-pipe';
@NgModule({
imports: [BrowserModule, OrderModule],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
export class AppModule {}
```
And use pipe in your component
```typescript
import { Component } from '@angular/core';
@Component({
selector: 'example',
template: `