WatermelonDB List Sorting

42 Views Asked by At

In my react native app, I have a post component. This post component uses withObservables from WatermelonDB to render the post and its comments:

const enhance = withObservables(["post"], ({ post }) => ({
    post,
    comments: post.comments
}));

const EnhancedPost = enhance(Post);

export default Post;

The comments for the post are rendered in a flatlist, like this:

<FlatList
    data={comments}
    key={"some-key"}
    renderItem={renderComment}
/>

I want to be able to sort these comments by a few different fields depending on what the user selects, such as title, author, date etc. How can I do this?

0

There are 0 best solutions below