# Interface Comparable<T>

All Known Implementing Classes:
  `ActionEvent.Type, AdFormat, AsyncMedia.MediaErrorType, AsyncMedia.State, AudioRecorderComponent.RecorderState, BarChart.Type, BindAttr, BiometricError, BiometricType, BodyType, BodyType, BrowserComponent.JSType, Byte, CameraFacing, Charset, Collision.PointState, ConnectionRequest.CachingMode, ContactID, ContactID.Type, Date, DialRenderer.Type, Double, Duration, ElementType, Enum, FlashMode, Float, FrameFormat, GradientDrawable.Orientation, Instant, Integer, JointType, LimitState, LlmException.ErrorType, LocalDate, LocalDateTime, LocalTime, Long, Manifold.ManifoldType, Material.Type, MultipleGradientPaint.ColorSpaceType, MultipleGradientPaint.CycleMethod, NfcError, NotificationPermissionResult.AuthorizationLevel, OffsetDateTime, Paint.Style, Pair, PointStyle, PrimitiveType, Promise.State, ProtoField.WireKind, RenderState.BlendMode, RenderState.CullMode, ResponseFormat, RetentionPolicy, Role, ScaleType, ShapeType, Short, SQLMap.SqlType, String, TagType, TextSelection.TextSelectionTrigger, Texture.Filter, Texture.Wrap, TimeOfImpact.TOIOutputState, Toolbar.BackCommandPolicy, Validator.HighlightMode, VertexAttribute.Usage, WebSocketState, WiFiSecurity, WindowEvent.Type, XYMultipleSeriesRenderer.Orientation, XYSeriesRenderer.FillOutsideLine.Type, ZonedDateTime`

public interface Comparable<T>

This interface should be implemented by all classes that wish to define a natural order of their instances. `java.util.Collections#sort` and `java.util.Arrays#sort` can then be used to automatically sort lists of classes that implement this interface.

The order rule must be both transitive (if `x.compareTo(y) < 0` and `y.compareTo(z) < 0`, then `x.compareTo(z) < 0` must hold) and invertible (the sign of the result of x.compareTo(y) must be equal to the negation of the sign of the result of y.compareTo(x) for all combinations of x and y).

In addition, it is recommended (but not required) that if and only if the result of x.compareTo(y) is zero, then the result of x.equals(y) should be `true`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(T another)`
  Compares this object to the specified object to determine their relative order.

- ## Method Details

  - ### compareTo

    int compareTo(T another)

    Compares this object to the specified object to determine their relative order.

    ###### Parameters

    - `another`: the object to compare to this instance.

    ###### Returns

    Returns:

      a negative integer if this instance is less than `another`; a positive integer if this instance is greater than `another`; 0 if this instance has the same order as `another`.

      ###### Throws

      - `ClassCastException`: @throws ClassCastException if `another` cannot be converted into something comparable to `this` instance.