How to make a chart with sorted values from a column?

Maybe it will be clearer if I explain my use case. As a teacher, I give scores to students ranging from 0 to 20. I made a very simple table with names of the students, their various scores, and finally their average score. If I just take a line, it looks like this (csv style) :

DOE; John; 12; 8; 10;

I would like to display a chart next to this table, showing the average score of every student, but sorted in the ascending order. I know it would be possible to sort the column and then make the chart, but I would have to do this again every time I change or add a score. Is there a way to automatically sort results in the chart without altering the column?

I assume that your chart is a bar chart with the student’s names on the x-axis and the average score on the y-axis.

If you are willing to allow your table to be sorted, here’s how to automatically update the chart as you want. Record a macro that sorts your grade table by the average score. Hook the macro to the “‘Modified’ status was changed” event for the spreadsheet. When you change a grade the chart is updated immediately. When you save the spreadsheet, the table is sorted and the chart is again updated using the sorted data.

If you want to maintain your original table sort order then it’s more complicated, but doable. Your macro should copy your table and paste it as values-only in another location, then the macro would sort the copy on the average grade. The chart would be based on the data copy, not the original data. The macro would be hooked to the ‘Modified’ event as above. You will want to turn off the warning about pasting into existing data.

I assume your answer is correct but by now I can’t validate it, as I discovered that the sort function is broken with my LO version (, at least under my OS (kubuntu). I provided some informations about this to an already existing unconfirmed bug ticket. I hope it will be corrected soon.