RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.2, Nov 26, 2026 ·

RunMat® is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

/
See all docs
Builtin Reference
    • argsort
    • intersect
    • ismember
    • ismembertol
    • issorted
    • issortedrows
    • setdiff
    • setxor
    • sort
    • sortrows
    • union
    • unique

issorted — Test whether arrays are sorted in MATLAB and RunMat.

issorted(A) tests whether data is already sorted. Dimension, order direction, strictness, missing placement, and row-wise modes follow MATLAB semantics.

Syntax

tf = issorted(A)
tf = issorted(A, arg1)
tf = issorted(A, arg1, arg2)
tf = issorted(A, ..., "ComparisonMethod", method)
tf = issorted(A, ..., "MissingPlacement", placement)

Inputs

A
Type
Any
Required
Yes
Description
Input array.
arg1
Type
Any
Required
Yes
Description
Dimension selector or direction token (including 'rows').
arg2
Type
Any
Required
Yes
Description
Direction token or additional mode selector.
arg
Type
Any
Required
Variadic
Description
Optional dimension/direction/rows arguments.
name
Type
StringScalar
Required
Yes
Default
"ComparisonMethod"
Description
Name-value option key.
method
Type
StringScalar
Required
Yes
Default
"auto"
Description
Comparison method: 'auto', 'real', or 'abs'.
name
Type
StringScalar
Required
Yes
Default
"MissingPlacement"
Description
Name-value option key.
placement
Type
StringScalar
Required
Yes
Default
"auto"
Description
Missing placement policy: 'auto', 'first', or 'last'.
NameTypeRequiredDefaultDescription
AAnyYes—Input array.
arg1AnyYes—Dimension selector or direction token (including 'rows').
arg2AnyYes—Direction token or additional mode selector.
argAnyVariadic—Optional dimension/direction/rows arguments.
nameStringScalarYes"ComparisonMethod"Name-value option key.
methodStringScalarYes"auto"Comparison method: 'auto', 'real', or 'abs'.
nameStringScalarYes"MissingPlacement"Name-value option key.
placementStringScalarYes"auto"Missing placement policy: 'auto', 'first', or 'last'.

Returns

tf
Type
LogicalArray
Description
True when data is already sorted by requested criteria.
NameTypeDescription
tfLogicalArrayTrue when data is already sorted by requested criteria.

Errors

RunMat:issorted:RowsRequiresTwoDimensionalInput
When
'rows' mode is used with non-2D input.
Message
issorted: 'rows' expects a 2-D matrix
RunMat:issorted:StringComparisonMethodUnsupported
When
ComparisonMethod is used with string arrays.
Message
issorted: 'ComparisonMethod' is not supported for string arrays
RunMat:issorted:DuplicateDirection
When
Multiple direction tokens are provided.
Message
issorted: sorting direction specified more than once
IdentifierWhenMessage
RunMat:issorted:RowsRequiresTwoDimensionalInput'rows' mode is used with non-2D input.issorted: 'rows' expects a 2-D matrix
RunMat:issorted:StringComparisonMethodUnsupportedComparisonMethod is used with string arrays.issorted: 'ComparisonMethod' is not supported for string arrays
RunMat:issorted:DuplicateDirectionMultiple direction tokens are provided.issorted: sorting direction specified more than once
RunMat:issorted:InvalidArgumentParser encounters invalid or unrecognized option/value arguments.issorted: invalid argument sequence
RunMat:issorted:InvalidInputInput type cannot be normalized into a supported sortable representation.issorted: invalid input type
RunMat:issorted:InternalInternal conversion/allocation paths fail.issorted: internal operation failed

Behavior

issorted(A) examines the first non-singleton dimension and returns a logical scalar.

issorted(A, dim) selects the dimension explicitly (1-based).

Direction flags include 'ascend', 'descend', 'monotonic', 'strictascend', 'strictdescend', and 'strictmonotonic'.

Name-value options mirror MATLAB:

'MissingPlacement' accepts 'auto', 'first', or 'last'.

'ComparisonMethod' accepts 'auto', 'real', or 'abs' for numeric and complex data.

issorted(A,'rows', ...) verifies lexicographic ordering of rows.

Logical and character arrays are promoted to double precision for comparison; string arrays are compared lexicographically, applying missing-placement rules only to typed missing elements.

Empty arrays, scalars, and singleton dimensions are always reported as sorted.

Types, placement and limitations

The result is a host logical scalar. Real, complex, logical, character and string data use dimension or row checks without changing the input. GPU input is gathered; nonvector GPU data and explicit GPU MissingPlacement require declared RunMat extensions.

Resident execution

These operations are eager fusion boundaries, not elementwise kernels or reductions, and do not broadcast. Provider availability does not imply a device-native sorting or set kernel: current providers may stage host work. An unsupported input can use exact host fallback before provider work starts. Errors after an attempt, including cancellation, are returned without repeating the operation on the host. Supported resident outputs return to their owning provider; predicates and all-indices cells have the host placement described above. Distributed execution is not supported.

Examples

Checking an ascending vector

A = [5 12 33 39 78 90 95 107];
tf = issorted(A)

Expected output:

tf =
     1

Verifying strict increase

B = [1 1 2 3];
tf = issorted(B, 'strictascend')

Expected output:

tf =
     0

Using a specific dimension

C = [1 4 2; 3 6 5];
tf = issorted(C, 2, 'descend')

Expected output:

tf =
     0

Allowing either ascending or descending order

D = [10 8 8 5 1];
tf = issorted(D, 'monotonic')

Expected output:

tf =
     1

Controlling missing placements

E = [NaN NaN 4 7];
tf = issorted(E, 'MissingPlacement', 'first')

Expected output:

tf = 1

Comparing complex data by magnitude

Z = [1+1i, 2+3i, 4+0i];
tf = issorted(Z, 'ComparisonMethod', 'abs')

Expected output:

tf =
     1

Checking row order

R = [1 2 3; 1 2 4; 2 0 1];
tf = issorted(R, 'rows')

Expected output:

tf =
     1

Working with string arrays

str = [ "apple" "banana"; "apple" "carrot" ];
tf = issorted(str, 2)

Expected output:

tf = 1

Using issorted with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how issorted changes the result.

Run a small issorted example, explain the result, then change one input and compare the output.

FAQ

Does issorted modify its input?⌄

No. The function inspects the data in-place and returns a logical scalar.

What is the difference between 'ascend' and 'strictascend'?⌄

'ascend' allows consecutive equal values, while 'strictascend' requires every element to be strictly greater than its predecessor and rejects missing values.

How does 'monotonic' work?⌄

'monotonic' succeeds when the data is entirely non-decreasing *or* non-increasing. Use 'strictmonotonic' to forbid repeated or missing values.

Can I control where NaN values appear?⌄

Yes. 'MissingPlacement','first' requires missing values to precede finite ones, 'last' requires them to trail, and 'auto' follows MATLAB’s default (end for ascending checks, start for descending).

Is 'ComparisonMethod' relevant for real data?⌄

For real data 'auto' and 'real' are identical. 'abs' compares magnitudes first and breaks ties using the signed value, matching MATLAB.

Does the function support GPU arrays?⌄

The result is a host logical scalar. Real, complex, logical, character and string data use dimension or row checks without changing the input. GPU input is gathered; nonvector GPU data and explicit GPU MissingPlacement require declared RunMat extensions. These operations are eager fusion boundaries, not elementwise kernels or reductions, and do not broadcast. Provider availability does not imply a device-native sorting or set kernel: current providers may stage host work. An unsupported input can use exact host fallback before provider work starts. Errors after an attempt, including cancellation, are returned without repeating the operation on the host. Supported resident outputs return to their owning provider; predicates and all-indices cells have the host placement described above. Distributed execution is not supported.

How are string arrays treated?⌄

Strings are compared lexicographically using Unicode code-point order. MissingPlacement rules apply to typed missing values. Literal <missing> text participates in ordinary lexicographic comparison.

What about empty arrays or dimensions of length 0?⌄

Empty slices are considered sorted. Passing a dimension larger than ndims(A) also returns true.

Related Array functions

Sorting Sets

argsort · intersect · ismember · ismembertol · issortedrows · setdiff · setxor · sort · sortrows · union · unique

Accumulation

accumarray

Shape

blkdiag · cat · circshift · diag · flip · fliplr · flipud · horzcat · ipermute · kron · permute · repelem · repmat · reshape · rot90 · shiftdim · squeeze · toeplitz · tril · triu · vertcat

Creation

colon · createArray · empty · eye · false · full · inf · int16.empty · int32.empty · int64.empty · int8.empty · linspace · logspace · magic · meshgrid · nan · ndgrid · nonzeros · ones · peaks · rand · randi · randn · randperm · range · sparse · spdiags · speye · spones · sprand · true · uint16.empty · uint32.empty · uint64.empty · uint8.empty · zeros

Combinatorics

combinations · nchoosek · perms

Binning

discretize

Indexing

find · ind2sub · sub2ind

Grouping

findgroups · groupcounts · grp2idx · splitapply

Introspection

height · iscolumn · isempty · ismatrix · isrow · isscalar · isvector · length · ndims · numel · size · width

Source you can read

Every RunMat function's source is public. Read exactly how issorted is executed, line by line, in Rust.

  • View the source for issorted in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • Behavior
  • Types, placement and limitations
  • Resident execution
  • Examples
  • Checking an ascending vector
  • Verifying strict increase
  • Using a specific dimension
  • Allowing either ascending or descending order
  • Controlling missing placements
  • Comparing complex data by magnitude
  • Checking row order
  • Working with string arrays
  • Using issorted with coding agents
  • FAQ
  • Related Array functions
  • Sorting Sets
  • Accumulation
  • Shape
  • Creation
  • Combinatorics
  • Binning
  • Indexing
  • Grouping
  • Introspection
  • Source you can read
  • About RunMat