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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:43:37+00:00 2026-06-03T00:43:37+00:00

I have a few arrrays which I am trying to combine in a certain

  • 0

I have a few arrrays which I am trying to combine in a certain order. For example, lets say I have three arrays:

var arrayOne = [1a, 1b, 1c];
var arrayTwo = [2a, 2b, 2c];
var arrayThree [3a, 3b, 3c];

how would I get something like this?

var combinedArray = [1a, 2a, 3a, 1b, 2b, 3b, 1c, 2c, 3c] 

EDIT

Ok, I am going to add a little more to my story here since I have gotten some great responses and answers from everyone. Maybe this will be clearer. I have a SharePoint list which I am getting all of my information from. I am using SPServices to get my data from the list. I am also getting the version history of each list item and placing them into arrays so I can pull the data out of the SPServices loop and use it outside of the SharePoint stuff so I can try to order and display it as I want. (Please do not move this to SharePoint ).
This is all going to have to happen at runtime. So here is the first part. I am declaring global variables for each one of my list items:

var proModified6 = new Array();
var proHistory = new Array();
var assignedTo = new Array();
var startDate = new Array();
var endDate = new Array();
var status = new Array();
var project = new Array();
var history = new Array();


var listItems = new Array();


var regex = new RegExp("");

var i = 0;

Then I am filling the arrays with the SharePoint list info ( I am not going to put them all but each has a call like this one)

$().SPServices({
  operation: "GetVersionCollection",
      async: false,
      webURL: "http://devchrisl01/test",
      strlistID: "NewProjects",
      strlistItemID: proID[i],
      strFieldName: "Title",         

      completefunc: function (xdata, Status) {

        $(xdata.responseText).find("Version").each(function() {

       //alert(xdata.responseXML.xml);

       var xitem = $(this);
            var ID = xitem.attr('ID');
            var Project = xitem.attr('Title');
            var Modified = xitem.attr('Modified').split('T')[0];
            var ModifiedTime = xitem.attr('Modified').substring(11, 19);
           //var modifiedUl = "<td><b>" + Modified + " " + ModifiedTime + "</b></td>";
  //$('#versionList'+i+'').append(modifiedUl);

                  project.push(Project);
                  proModified2.push(Modified + ModifiedTime)


    // just looking at my data here not really part of my problem       
var data = "<tr><td><b>" + Modified + " " + ModifiedTime + "</b></td><td>" + Project + "</td></tr>";


$('#versionList'+i+'').append(data);

        });  

      }

});

After is where my question has come into play. I am getting all of my data back I need. I have not found a better way to store all of the list information and pull it out of the SPServices besides using an array for each. The kicker is I am not going to know how many arrays there are going to be or how long. Eventually this is going to be dynamic. (PAIN IN THE ASS ) so here are the arrays:

var modifiedDate = [proModified1, proModified2, proModified3, proModified4, proModified5, proModified6];
var projectHistory = [history];
var projectTitle = [project];
var projectAssignedTo = [assignedTo];
var projectStartDate = [startDate];
var projectEndDate = [endDate];
var projectStatus = [status];

Each one is going to be different. There is not going to be the same amount of them either for each user. I have just made my list static to build on first. List dynamics will be another question later :0

Is there going to be a way for me to do with these arrays like I asked in my simple example? See why I went simple first lol.

  • 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-03T00:43:39+00:00Added an answer on June 3, 2026 at 12:43 am

    Edit: Updated comparator as Salmon pointed out that it should return -1, 0 or 1.

    Try below,

    var arrayOne = ["1a", "1b", "1c"];
    var arrayTwo = ["2a", "2b", "2c"];
    var arrayThree = ["3a", "3b", "3c"];
    
    var combinedArray = arrayOne
        .concat(arrayTwo, arrayThree) //Concatenate the array.. can add any number of arrays
        .sort(function(a, b) { //Custom comparator for your data
           var a1 = a.charAt(1);
           var b1 = b.charAt(1);
    
           if (a1 == b1) return 0;
           if (a1 < b1) return -1;
           return 1;
        });
    

    Note: The custom comparator function is very specific to your data. Update the function as you need.

    DEMO

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

Sidebar

Related Questions

I have few Question for which I am not able to get a proper
I have few text and excel file, from which I need to import data
I have few buttons of which each button is assigned a class with a
I have few jar files which I am not getting from any repositories.I have
I have been trying to code merge sort, without creating additional arrays for keeping
I would like to have at least 2 arrays which I can create when
I have a few questions about getters and setters for arrays. Suppose we have
I have a model which returns to controller arrays of user's information (his posts,
In my application , I have few parameters (zone_id, startdate, enddate, brand, model) which
I have a few arrays and a resource that needs deletion, the value of

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.