Monday, April 16, 2012

how to achieve this result

I am working on small project using Python 2.6. Finally my list is like this.

data = ['1:Rammmm,mmmm', '2:surr.rrrrr', '3:Sam ttttt',
'1:qqqq qqqqqqq', '2:wwwwwwwwwww', '3:eeeeeeeee','4:tttttttt',
'1:zzzzzzzzzzzzz', '2:xxxxxxxxx']

Here, I want to display all 1's in one line, all 2's in one line, etc., with pipe"|" as separator. It should be like this with sorting order.

{Rammmm,mmmm|qqqq qqqqqqq|zzzzzzzzzzzzz}
{Sam ttttt|eeeeeeeee}

How can this be achieved in Python?

No comments:

Post a Comment