Sorting list of URLs by length in Jython

Posted by Eef on Stack Overflow See other posts from Stack Overflow or by Eef
Published on 2008-10-30T10:02:52Z Indexed on 2010/06/18 2:53 UTC
Read the original article Hit count: 384

Filed under:
|
|
|

Hi,

I am writing a Jython script to sort a list of URLs.

I have a list that looks like this:

http://www.domain.com/folder1/folder2/|,1
http://www.domain.com/folder1/|,1
http://www.domain.com/folder1/folder2/folder3/|,1
http://www.domain.com/folder1/|,1
http://www.domain.com/folder1/folder2/|,1
http://www.domain.com/folder1/folder2/|,1
http://www.domain.com/folder1/folder2/folder3/|,1

The pipe and the comma separates the path from the amount of files that are under that path. Is it possible some how use Jython to order the URLs by length, so it would end up look like the below list:

http://www.domain.com/folder1/|,1
http://www.domain.com/folder1/|,1
http://www.domain.com/folder1/folder2/|,1
http://www.domain.com/folder1/folder2/|,1
http://www.domain.com/folder1/folder2/|,1
http://www.domain.com/folder1/folder2/folder3/|,1
http://www.domain.com/folder1/folder2/folder3/|,1

Hope you guys get what I mean, any help would be appreciated. Cheers

© Stack Overflow or respective owner

Related posts about url

Related posts about list