# Interface Comparable<T>

All Known Implementing Classes:
  `AccessibilityCheckedState, AccessibilityColorVisionDeficiency, AccessibilityGrouping, AccessibilityIssue.Severity, AccessibilityLiveRegion, AccessibilityRole, AccessoryCategory, ActionEvent.Type, AdapterState, AdFormat, AdvertiseMode, AggregateMetric, AirQualityLevel, AlarmState, AnalyticsCapability, AndroidMinSdk, ARAnchorEvent.Kind, ARFaceRegion, ARHitResult.Type, ARPlane.Type, ARPlaneDetection, ARPlaneEvent.Kind, ARTrackingFailureReason, ARTrackingMode, ARTrackingState, AssetDef.Kind, AssetDef.Type, AsyncMedia.MediaErrorType, AsyncMedia.State, AudioRecorderComponent.RecorderState, BarChart.Type, BindAttr, BiometricError, BiometricType, BluetoothError, BluetoothPermission, BodyType, BodyType, BondState, BrowserComponent.JSType, Byte, CalendarAccess, CalendarAlarm.Method, CalendarAttendee.Response, CalendarAttendee.Role, CalendarAuthorizationStatus, CalendarCapability, CalendarChange.ChangeType, CalendarChange.EntityType, CalendarConflict.Resolution, CalendarError, CalendarEvent.Availability, CalendarEvent.Privacy, CalendarEvent.Status, CalendarInfo.ContentType, CalendarMutationScope, CalendarRecurrenceRule.Frequency, CallAudioRoute, CallAvailability, CallDirection, CallEndReason, CallError, CallHandleType, CallState, CameraFacing, CarColor, ChargingState, Charset, Collision.PointState, CommissioningStyle, CompanionProfile, ConnectionPriority, ConnectionRequest.CachingMode, ConnectionState, ConsentMode, ContactID, ContactID.Type, Date, DesktopTitleBar, DeviceType, DialRenderer.Type, DoorState, Double, Duration, ElementType, EntityQuery.Kind, Enum, Exposure, FailureMode, FanMode, FileAccess, FlashMode, Float, FrameFormat, GameLevel.Mode, GattStatus, GlassRecipe.Kind, GlucoseRecordFilter.Kind, GradientDrawable.Orientation, HardenControlFlow, HardenLevel, HardenStrings, HealthAggregationStyle, HealthAuthorizationStatus, HealthAvailability, HealthDataKind, HealthError, HealthRequestStatus, HealthUnitDimension, HeatingCoolingMode, HintKind, HomeAuthorizationStatus, HomeAvailability, HomeBackend, HomeError, InferenceOptions.Accelerator, InstallLocation, Instant, Integer, IntentParameterType, IntentSource, IosDependencyManager, IosProjectType, JointType, Layer.Kind, LimitState, LlmException.ErrorType, LocalDate, LocalDateTime, LocalTime, LockState, Long, Manifold.ManifoldType, Material.Type, MCPVerbosity, MultipleGradientPaint.ColorSpaceType, MultipleGradientPaint.CycleMethod, NearbyAvailability, NearbyError, NearbyPermission, NfcError, NotificationPermissionResult.AuthorizationLevel, OffsetDateTime, Paint.Style, Pair, PayloadStatus, PointStyle, PositionState, PrimitiveType, Promise.State, ProtoField.WireKind, RangingRemovalReason, RangingRole, RangingUnit, RecordingMethod, RenderState.BlendMode, RenderState.CullMode, ResponseFormat, RetentionPolicy, RichTextComponent.SizeMode, RichTextFormat, Role, ScaleType, ScanMode, SceneType, SensorSessionState, ServiceType, ShapeType, Short, SleepStage, SleepStageSupport, SQLMap.SqlType, String, StructureChangeKind, SurfaceAlignment, SurfaceFontWeight, TagType, TapjackingPolicy, TensorType, TextSelection.TextSelectionTrigger, Texture.Filter, Texture.Wrap, ThemeMode, TimeOfImpact.TOIOutputState, Toggle, Toolbar.BackCommandPolicy, TraitUnit, TraitUnitDimension, TraitValueKind, TransportStrategy, TravelMode, TunnelStopReason, TxPowerLevel, Validator.HighlightMode, VertexAttribute.Usage, VisionFeature, VpnError, VpnProtocol, VpnStatus, VREye, WebSocketState, WidgetSize, WiFiSecurity, WindowEvent.Type, WorkoutActivityType, WorkoutEvent.Kind, WorkoutLocationType, WorkoutSessionState, 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.