Just because of the sheer volume involved, ranking TV is really, really hard. Alan Sepinwall and Matt Zoller Seitz, who are two well-known TV critics, put out a book about 5 years ago (TV: The Book) where they had a good discussion about the merits of comedy versus drama, older shows versus new shows, etc. For the record, their top ten (which included comedies, but also focused on North American TV) was:
1) The Simpsons
2) The Sopranos
3) The Wire
4) Cheers
5) Breaking Bad
6) Mad Men
7) Seinfeld
8) I Love Lucy
9) Deadwood
10) All in the Family