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 8185255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T01:47:05+00:00 2026-06-07T01:47:05+00:00

I have a Job class. Here’s a simplified version with some sample jobs: class

  • 0

I have a Job class. Here’s a simplified version with some sample jobs:

class Job:
    def __init__(self, type):
        self.type = type
    def __repr__(self):
        return '< %s >' % self.type

job1 = Job('Copy')
job2 = Job('Delete')
job3 = Job('Scan')

jobs = [job1,job2,job3]

In my application, the jobs are added to the jobs list (from a db) somewhat randomly, but I need to ensure that any Delete jobs take place last. The simplest way I can think of is to ensure the Delete jobs are moved to the end of the list, then the list is processed in order. However, I’m not sure how to do that when the sort criteria is an attribute of a Class, and is there any guaranty that the list will be iterated in order when the jobs are processed? Any advice would be great.

  • 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-06-07T01:47:06+00:00Added an answer on June 7, 2026 at 1:47 am
    jobs.sort(key=lambda x:x.type=="Delete")
    

    The key will be False for “Copy” or “Scan” jobs and True for “Delete” jobs. Since True > False the “Delete” jobs will be sorted to the end

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two models: class Category has many :jobs end class Job belongs_to :category
Just looking for some advice here on a small job I have to do.
Hey we have a library class (lib/Mixpanel) that calls delayed job as follows: class
I have the following models class Person(models.Model): name = models.CharField(max_length=100) class Employee(Person): job =
I have a simple class called Job with a public ctor and public function
Hey, need a little help here. I have two models: class User < ActiveRecord::Base
I need some help with nested resource actions. I have three nested resources: Jobs,
I am using Quartz JDBCJobStore and have following job definition JobDetail job=newJob(HelloJob.class).withIdentity(demo11, group11). usingJobData(jobSays,
I have a job object for long running operations that works like this: Class
I have created a singleton class whose job is to create a tcp socket

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.