# Meaning of \`isless\`, \`\<\`, \`cmp\`, \`isequal\`, \`==\`, total order, partial order, unordered

**URL:** <https://discourse.julialang.org/t/meaning-of-isless-cmp-isequal-total-order-partial-order-unordered/8176>\
**Category:** Internals & Design\
**Created:** [January 5, 2018, 2:25pm UTC](https://discourse.julialang.org/t/meaning-of-isless-cmp-isequal-total-order-partial-order-unordered/8176 "2018-01-05T14:25:19Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![klacru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klacru/32/27890_2.png) [@klacru](https://discourse.julialang.org/u/klacru)\
**Post date:** [January 6, 2018, 3:05pm UTC](https://discourse.julialang.org/t/meaning-of-isless-cmp-isequal-total-order-partial-order-unordered/8176/21 "2018-01-06T15:05:46Z")

</div>

Sorry for my wrong wording and the error in the code snippet.  
By elementwise, I meant: `A < B <=> for all i: a[i] < b[i]`.

---

<div class="post-metadata">

**Author:** ![klacru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klacru/32/27890_2.png) [@klacru](https://discourse.julialang.org/u/klacru)\
**Post date:** [January 6, 2018, 9:15pm UTC](https://discourse.julialang.org/t/meaning-of-isless-cmp-isequal-total-order-partial-order-unordered/8176/22 "2018-01-06T21:15:29Z")

</div>

> [@stevengj](#):
>
> \<(a,b) = all(isless.(a,b))? I don’t think this would be terribly useful.

why not? That is the standard partial order for functions. Array may be considered as a function that is mapping its index set to its values.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 6, 2018, 9:37pm UTC](https://discourse.julialang.org/t/meaning-of-isless-cmp-isequal-total-order-partial-order-unordered/8176/23 "2018-01-06T21:37:21Z")

</div>

> [@klacru](#):
>
> why not? That is the standard partial order for functions.

In a narrow set of contexts, this comparison could useful for arrays, but in the standard library I don’t think it is useful to define a `<` function in which most arguments are unordered.

---

<div class="post-metadata">

**Author:** ![klacru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klacru/32/27890_2.png) [@klacru](https://discourse.julialang.org/u/klacru)\
**Post date:** [January 7, 2018, 11:15am UTC](https://discourse.julialang.org/t/meaning-of-isless-cmp-isequal-total-order-partial-order-unordered/8176/24 "2018-01-07T11:15:38Z")

</div>

> [@stevengj](#):
>
> In a narrow set of contexts, this comparison could useful for arrays, but …

True. That is the same argument, which let me dislike to define `isless` for arrays in general (even vectors).

---

<div class="post-metadata">

**Author:** ![klacru](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/klacru/32/27890_2.png) [@klacru](https://discourse.julialang.org/u/klacru)\
**Post date:** [January 7, 2018, 11:39am UTC](https://discourse.julialang.org/t/meaning-of-isless-cmp-isequal-total-order-partial-order-unordered/8176/25 "2018-01-07T11:39:13Z")

</div>

There is another argument: If we define `isless`/`cmp` for `AbstractArray` that will be usable for all subtypes. Many of them would cry for specialized implementations for performance reasons. The current list:

```julia
julia> subtypes(AbstractArray)
29-element Array{Union{DataType, UnionAll},1}:
 AbstractRange                      
 AbstractSparseArray                
 Adjoint                            
 Base.LinAlg.AbstractQ              
 Base.LinAlg.AbstractTriangular     
 Base.LinAlg.HessenbergQ            
 Base.LinAlg.LQPackedQ              
 Base.LogicalIndex                  
 Base.ReinterpretArray              
 Base.ReshapedArray                 
 Bidiagonal                         
 CartesianIndices                   
 ConjArray                          
 Core.Inference.AbstractRange       
 DenseArray                         
 Diagonal                           
 Hermitian                          
 IterativeEigensolvers.AtA_or_AAt   
 IterativeEigensolvers.SVDAugmented 
 LinearIndices                      
 PermutedDimsArray                  
 RowVector                          
 SubArray                           
 SuiteSparse.CHOLMOD.FactorComponent
 SymTridiagonal                     
 Symmetric                          
 Test.GenericArray                  
 Transpose                          
 Tridiagonal                        

julia> 

```

[Previous page](https://discourse.julialang.org/t/meaning-of-isless-cmp-isequal-total-order-partial-order-unordered/8176.md?page=1)
