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 SortAs method, sort a items slice by another keys slice #297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alingse
Copy link

@alingse alingse commented Jan 5, 2023

i have many case look like this

func FetchData() {
    var itemIDs = []int{3, 4, 1, 2}
    var items = db.Execute("select * from table where id in ?",  itemIDs).FindItems()
    return items
}

the itemIDs was not in order given by another table.
but the db return the items always by the default order by id,which was not expected as the index of itemIDs

we need to build a map[id]item and sometimes map[id][]item and then join it.

maybe we can use the exists data to do a for loop to solve the problem,but

i think SortAs is still a useful function.

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 this pull request may close these issues.

1 participant