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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:25:53+00:00 2026-06-09T23:25:53+00:00

I have the following code as part of a table sorting script. As it

  • 0

I have the following code as part of a table sorting script. As it is now, it allows names in the “FIRST LAST” format to be sorted on LAST name by “reformatting” to “LAST, FIRST”.

var FullName = fdTableSort.sortText;
function FullNamePrepareData(td, innerText) {
  var a = td.getElementsByTagName('A')[0].innerHTML;
  var s = innerText.split(' ');
  var r = '';
  for (var i = s.length; i > 0; i--) {
    r += s[i - 1] + ', ';
  }
  return r;
}

It currently seems to sort on the name after the LAST space (ex. Jean-Claude Van Damme would sort on ‘D’).

How could I change this script to sort on the FIRST space (so Van Damme shows up in the V’s)?

Thanks in advance!

  • 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-09T23:25:55+00:00Added an answer on June 9, 2026 at 11:25 pm

    Instead of the .split() and the loop you could do a replace:

    return innerText.replace(/^([^\s]+)\s(.+)$/,"$2, $1");
    

    That is, find all the characters up to the first space with ([^\s]+) and swap it with the characters after the first space (.+), inserting a comma at the same time.

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

Sidebar

Related Questions

I have the following code but it keeps presenting errors. The first part of
Using linkedin-j , I have the following code in one part of my application
I have the following code in one cpp file which is part of a
Ok - I have the following code - on the starred part I get
I have the following code, which is run every 10ms as part of a
I have the following code : System.out.println(new String(–’.getBytes(ISO8859_15_FDIS))); The two characters in the first
Using the Entity Framework Code First paradigm I have defined the following objects and
I have created the following code as part of an excercise in a Ruby
How to update table data with data stored in session? I have following code
I have inserted the following java code in the body part of my jsp

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.