# Class SAMRecordQueryNameComparator

java.lang.Object
htsjdk.samtools.SAMRecordQueryNameComparator

All Implemented Interfaces:
  `SAMRecordComparator, Serializable, Comparator<SAMRecord>`

Direct Known Subclasses:
  `SAMRecordQueryHashComparator`

public class SAMRecordQueryNameComparator extends Object implements SAMRecordComparator, Serializable
Comparator for "queryname" ordering of SAMRecords.

See Also:
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`SAMRecordQueryNameComparator()`

## Method Summary

Modifier and Type
Method
Description
`int`
`compare(SAMRecord samRecord1, SAMRecord samRecord2)`
`static int`
`compareReadNames(String readName1, String readName2)`
Encapsulate algorithm for comparing read names in queryname-sorted file, since there have been conversations about changing the behavior.
`int`
`fileOrderCompare(SAMRecord samRecord1, SAMRecord samRecord2)`
Less stringent compare method than the regular compare.

### Methods inherited from class Object

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

### Methods inherited from interface Comparator

`equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

## Constructor Details

### SAMRecordQueryNameComparator

public SAMRecordQueryNameComparator()

## Method Details

### compare

public int compare(SAMRecord samRecord1, SAMRecord samRecord2)

Specified by:
  `compare` in interface `Comparator<SAMRecord>`

### fileOrderCompare

public int fileOrderCompare(SAMRecord samRecord1, SAMRecord samRecord2)
Less stringent compare method than the regular compare. If the two records are equal enough that their ordering in a sorted SAM file would be arbitrary, this method returns 0.

Specified by:
  `fileOrderCompare` in interface `SAMRecordComparator`
Returns:
  negative if `samRecord1 < samRecord2`, 0 if equal, else positive

### compareReadNames

public static int compareReadNames(String readName1, String readName2)
Encapsulate algorithm for comparing read names in queryname-sorted file, since there have been conversations about changing the behavior.