If you do not want to use the java snipplet but prefer to do everything in knime, then first sort the data with the normal sort node, but sort on both columns, Primary on ID and secondary on Data.
Then your data will be presorted and look like
ID
Value
a
1
a
2
a
3
a
5
a
8
b
1
After that, as darbon suggested, use the group by node.