Let's say I want Google Spreadsheets to automagically sort some data, for example column
C. How do I do that?
I know that I can manually sort data by right-clicking and selecting Sort data, but this is not what I'm looking for.
Here's a generic script that will autosort based on the 1st column, and assumes a Header row.
To create a script:
In the empty code window, paste the following code, which will run automatically whenever a cell is edited:
It is also possible to use Google Apps Scripts to achieve automatic in-place sorting of the data.
This may be more difficult to achieve and more error-prone (I'd still go for William Jackson's solution, +1 BTW), but I thought it was interesting enough to show.
I have a sheet that looks like this:
I added a new script, using these steps:
In the above script,
Your table will most likely differ from mine, so these values should be adjusted accordingly.
You can use the
For example, say I have Sheet1 with my data:
Then in Sheet2, cell A1, I would put this function:
This would show my data, but sorted by column C (the third column), ascending.