Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isless variant where missing is smallest #142

Closed
bkamins opened this issue Feb 17, 2022 · 10 comments · Fixed by #144
Closed

Add isless variant where missing is smallest #142

bkamins opened this issue Feb 17, 2022 · 10 comments · Fixed by #144

Comments

@bkamins
Copy link
Member

bkamins commented Feb 17, 2022

The definitions to make missing smallest would be

isless2(::Missing, ::Missing) = false
isless2(::Missing, ::Any) = true
isless2(::Any, ::Missing) = false
isless2(x, y) = isless(x, y)

@nalimilan - the question is what should be the name of this function (as usual this is the hardest part).

Also a question is if Missings.jl should export it (I think it is OK to export it if we find a good name)

@nalimilan
Copy link
Member

islessmissingsmallest or islessmissingfirst would be explicit though a bit long...

@bkamins
Copy link
Member Author

bkamins commented Feb 17, 2022

This is my fear. Let us ask on Slack.

@sprmnt21
Copy link

let's start by removing isless, since it is the default value
missingassmallest
missingissmallest

@nalimilan
Copy link
Member

We could also say missingisless since this function really does this: consider that missing is less than all other values.

@bkamins
Copy link
Member Author

bkamins commented Feb 17, 2022

missingless? (without s in the middle)

@sprmnt21
Copy link

it sounds like a play on words (or is it? I like it).
missingless could be read as no missing

@alejandromerchan
Copy link

You guys obviously know way more than me with regards of design and philosophy of these packages, but I thought of this operation as sort acting in somehow in combination with skipmissing. I don't know if that's the right approach an what consequences you have from this, but something like sort(df, :A, rev = true, skipmissing = true) was the operation I was hoping to have.

@bkamins
Copy link
Member Author

bkamins commented Feb 17, 2022

The approach we are discussing is more general and would allow you to sort any collection, e.g. a vector in exactly the same way.

@nalimilan
Copy link
Member

Any objections to missingisless?

BTW, since the main use case is to do sort(x, lt=missingisless, rev=true), we could directly provide a function which reverses the order. But I don't have a good name for that (missingisnotgreater?)

@bkamins
Copy link
Member Author

bkamins commented Mar 29, 2022

missingisnotgreater feels unclear.

missingisless seems OK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants