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

Sorting #829

Open
mbinette opened this issue Nov 13, 2024 · 3 comments
Open

Sorting #829

mbinette opened this issue Nov 13, 2024 · 3 comments

Comments

@mbinette
Copy link

Is anyone sorting with v3? I was on v1 and Sheet.Rows was a slice, and we implemented the sort interface (Less and Swap). I can use the new Sheet.Row(index) function to get a pointer to the row, but I can't see how to implement Swap since I don't have access to the underlying cellStore. In v1 we could do Sheet.Row[a], Sheet.Row[b] = Sheet.Row[b], Sheet.Row[a] to swap to rows in the sheet.

We are actually sorting by multiple columns. I don't see any way of adding anything to tell Excel how to sort. I did see a closed issue requesting that feature.

If I knew how to swap two rows, my current implementation would continue to work.

@tealeg
Copy link
Owner

tealeg commented Nov 18, 2024

@mbinette I'm kind of hesitant to expose the cellstore implementation at runtime. It might make sense to add an implementation of the sort.Interface to the CellStore and CellStoreRow interfaces.

@mbinette
Copy link
Author

I think if you were to add anything to the CellStore interface, it would be something like the OrderedBy example at https://pkg.go.dev/sort as the Example (SortMultiKeys).

Looking at the default MemoryCellStore and MemoryRow, I think I can probably copy it and modify a little to create a SortedCellStore and SortedMemoryRow. I know the sort order before I add data so I could sort as data is added or add the sort.Interface to just my own custom store.

@tealeg
Copy link
Owner

tealeg commented Nov 20, 2024

@mbinette - yes, the MemoryCellStore is probably quite easy to make sortable. The DiskVCellStore would be harder

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

No branches or pull requests

2 participants