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

  • SEARCH
  • Home
  • 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 1057965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T17:57:08+00:00 2026-05-16T17:57:08+00:00

I’ll to explain this right: I’m in an environment where I can’t use python

  • 0

I’ll to explain this right:
I’m in an environment where I can’t use python built-in functions (like ‘sorted’, ‘set’), can’t declare methods, can’t make conditions (if), and can’t make loops, except for:

  • can call methods (but just one each time, and saving returns on another variable

    foo python:item.sort(); #foo variable takes the value that item.sort() returns

    bar python:foo.index(x);

  • and can do list comprehension

    [item[‘bla’] for item in foo]

…what I don’t think that will help on this question

I have a ‘correct_order’ list, with this values:

correct_order = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

and I have a ‘messed_order’ list, with this values:

messed_order = [55, 1, 44, 3, 66, 5, 4, 7, 2, 9, 0, 10, 6, 8]

Well, I have to reorder the ‘messed_order’ list, using the index of ‘correct_order’ as base. The order of the rest of items not included in correct_order doesn’t matter.

Something like this would solve (again, except that I can’t use loops):

for item in correct_order:
    messed_order[messed_order.index(item)], messed_order[correct_order.index(item)] = messed_order[correct_order.index(item)], messed_order[messed_order.index(item)]

And would result on the ‘ordered_list’ that I want:

[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 55, 66, 44]

So, how can I do this?

For those who know zope/plone, I’m on a skin page (.pt), that doesn’t have a helper python script (what I think that is not possible for skin pages, only for browser pages. If it is, show me how and I’ll do it).

  • 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. Editorial Team
    Editorial Team
    2026-05-16T17:57:09+00:00Added an answer on May 16, 2026 at 5:57 pm

    It’s hard to answer, not knowing exactly what’s allowed and what’s not. But how about this O(N^2) solution?

    [x for x in correct_order if x in messed_order] + [x for x in messed_order if x not in correct_order]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I would like to count the length of a string with PHP. The string
I have a jquery bug and I've been looking for hours now, I can't

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.