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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:50:31+00:00 2026-06-01T01:50:31+00:00

I have records in the database with the sort order number. Now I want

  • 0

I have records in the database with the sort order number. Now I want to create a UI with buttons UP and DOWN to reorder them. What is the best algorithm to make two functionsUp(record) and functionDown(record) in order to rearrange them by changing orderNum and them persist that number to the database.

Here is the example of what I’m trying to achieve (before foo=24, after foo=25):

Before pressing up on bar

id | name | orderNum
-------------------- 
1  | foo  | 24
2  | bar  | 25
3  | doe  | 26

After

id | name | orderNum
-------------------- 
1  | foo  | 25
2  | bar  | 24
3  | doe  | 26
  • 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-01T01:50:33+00:00Added an answer on June 1, 2026 at 1:50 am

    Assuming that you are using Java Collections, you can write a class that implements Comparable and use the utility Collections.sort(). More info about ordering colletions here.

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

Sidebar

Related Questions

I have stored various records in the MySql database orkut. Now I want to
Suppose i have 1kk records in my database. Now i need to select some
I want to check my database for records that I already have recorded before
I'm using LINQ to SQL to pull records from a database, sort them by
I want the result set of a database query to have a certain order.
I have like 400 records on my database, suppose this is the first version
i have total 70,000 records in database. currently i displays all the records in
I have a function which calculates distance from database records. This function is called
I have an app which will generate 5 - 10 new database records in
I have a gridview and sqldatasource. I'm trying to insert new records in database

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.