# Class SAMSortOrderChecker

java.lang.Object
htsjdk.samtools.SAMSortOrderChecker

public class SAMSortOrderChecker extends Object
Encapsulates simple check for SAMRecord order.

## Constructor Summary

Constructors
Constructor
Description
`SAMSortOrderChecker(SAMFileHeader.SortOrder sortOrder)`

## Method Summary

Modifier and Type
Method
Description
`SAMRecord`
`getPreviousRecord()`
`String`
`getSortKey(SAMRecord rec)`
Return the sort key used for the given sort order.
`SAMFileHeader.SortOrder`
`getSortOrder()`
`boolean`
`isSorted(SAMRecord rec)`
Check if given SAMRecord violates sort order relative to previous SAMRecord.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SAMSortOrderChecker

public SAMSortOrderChecker(SAMFileHeader.SortOrder sortOrder)

## Method Details

### isSorted

public boolean isSorted(SAMRecord rec)
Check if given SAMRecord violates sort order relative to previous SAMRecord.

Returns:
  True if sort order is unsorted, if this is the first record, or if `previous <= rec`.

### getPreviousRecord

public SAMRecord getPreviousRecord()

### getSortOrder

public SAMFileHeader.SortOrder getSortOrder()

### getSortKey

public String getSortKey(SAMRecord rec)
Return the sort key used for the given sort order. Useful in error messages. This should only be used in error messages and program correctness should not rely on this.