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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:55:07+00:00 2026-06-10T05:55:07+00:00

Most questions about advanced ordering involve a few prioritized fields, but here’s a different

  • 0

Most questions about advanced ordering involve a few prioritized fields, but here’s a different problem.

I have a series of projects ordered by title, and these projects are assigned to individuals in the company. I want to be able to have each individual’s projects float to the top for that individual.

This is not a request to order by assigned_individual then job_title (because this would mess up the ordering of all projects that aren’t mine). This is a request to have records still ordered principally by job_title but to have an override such that records with, let’s say, assigned_individual_id = 3 are shown first.

  • 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-10T05:55:08+00:00Added an answer on June 10, 2026 at 5:55 am

    Not hard, you just have to slip a CASE into your ORDER BY to manually push the rows of interest to the top, something like this:

    id = M.send(:sanitize_sql, ['?', id])
    M.order("case when assigned_individual = #{id} then 0 else 1 end, job_title")
    

    where, of course, id is the user that you want on top. If this is done inside one of M’s methods then you won’t need to use send to get around the protectedness of sanitize_sql.

    This technique can easily be extended to push multiple users to the top if that’s needed.

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

Sidebar

Related Questions

I have searched stackoverflow for a question like mine but most of the questions
I realize that there are many similar questions, but most involve scaling down the
I have a several questions about hibernate. In many questions here in stackoverflow, several
I see some related questions have been asked, but they're either too advanced for
i am building an android application but i have some questions about the memory
I have a few questions about Grit/Git that I hope you can help me
While most questions are about grouping nodes based on similarity (pidgeonholes), I would like
Question about logics here: What's the most elegant way to make the menu appear/disappear
There are a few examples on unobtrusive events for pure JS. Most of questions
This post on SO answers most of the questions I have (much thanks to

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.