Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 69851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:38:20+00:00 2026-05-10T19:38:20+00:00

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

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:38:20+00:00Added an answer on May 10, 2026 at 7:38 pm

    Sort-by-length, using a sort function:

    urls.sort(lambda a, b: cmp(len(a), len(b))) 

    For performance, some might prefer the decorate-sort-undecorate pattern:

    urllengths= [(len(url), url) for url in urls] urllengths.sort() urls= [url for (l, url) in urllengths] 

    Or as a one-liner:

    urls= zip(*sorted((len(url), url) for url in urls))[1] 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Writing something like this using the loki library , typedef Functor<void> BitButtonPushHandler; throws a
I am writing a script at the moment that will grab certain information from
I am writing jython application with eclipse SWT/JFace. I have to pass float array
I´m writing an application for Android in which I have a character that I
Writing a JSP page, what exactly does the <c:out> do? I've noticed that the
I writing a report in Visual Studio that takes a user input parameter and
So I've been pigeon-holed into writing some Jython code. I've been using the latest
I am writing a package in python that talks to an ldap server. I
Im writing an ipad application. So far what I have is a Delegate and
Background: writing an automated release script to export changed files between versions from SVN

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.