reset password
Author Message
abajpai
Posts: 52
Posted 16:36 Apr 11, 2011 |

This is more of an observation than a question, But I guess it's a bit of both. For the part of the homework that says sort the posted questions by date in descending order, is there really a need to manually sort the entries? If you think about it, the structure of the storage holding the questions allows for the display of the questions in descending order of time by default, because they are stored as they are created, and logically thinking, a 2nd post can only be created after the first. Or at least that is how I think of it. So doesn't that mean they are already sorted in the order required? Or am I thinking something wrong here?

cysun
Posts: 2935
Posted 16:48 Apr 11, 2011 |

First of all, for the assignment, if you store the questions in a list, then they are in ascending order of post time, not descending order.

In practice, sites like stackoverflow often let users to sort based on different criteria (e.g. by question post time, by answer post time, by number of votes, etc.), and the data structure to store the questions may not be a list, so in general we shouldn't assume the questions will always be in certain order.

cbort
Posts: 95
Posted 17:09 Apr 11, 2011 |

 

Last edited by cbort at 17:11 Apr 11, 2011.
Vanquish39
Posts: 134
Posted 21:02 Apr 11, 2011 |

Just use the comparable interface for sorting the post time strings.  Or you can use the comparator interface.

abajpai
Posts: 52
Posted 23:58 Apr 12, 2011 |

Do we need to sort the answers on a question and the page with questions of any one tag (that the user clicks on from the main page) chronologically too?

Last edited by abajpai at 00:00 Apr 13, 2011.
cysun
Posts: 2935
Posted 10:32 Apr 13, 2011 |
abajpai wrote:

Do we need to sort the answers on a question and the page with questions of any one tag (that the user clicks on from the main page) chronologically too?

So that's two questions:

1. Sort answers?

No for HW1, but Yes for HW2 (sort based on votes).

2. Sort questions with a tag after a user clicks on the tag on the question list page?

Yes.

abajpai
Posts: 52
Posted 10:35 Apr 13, 2011 |

Thank you professor