Completion sort by relevance

Is there a way, either in completion-nvim, nvim-compe, or anything else, to sort by nearest or most related to nearest?
The majority of the time, words I’m likely to need are the same as nearby words or related to nearby words(‘related’ meaning members/functions/etc of nearby words).

however, the majority of the time the completion suggestion that I need is at or near the bottom of the list.

if I remember correctly, isnt one of the ins-completion modes about results from the same line?

I know that in completion-nvim you can chain and order your sources, perhaps you could do something like

vim.g.completion_chain_complete_list = {
        yourfiletype = {
            {mode = "line"},
            {complete_items = {"lsp", "snippet"}},    
            {"other modes"}

And you could add this
vim.g.completion_auto_change_source = 1 so that current line is comes first and lsp comes after but in the same pumvisible dropdown instead of having to use keystrokes to switch the sources

There are other ways of prioritizing but I dont know them personally

yes it seems the best you can do is play around with setting the priorities of the completion sources and the sorting of their individual results.