Is there a clean way of splitting a List in half and making two of them, one for the first half and the other for the second half?

The goal is to create a two column slds grid to show the list evenly in two smaller columns rather than one long column. Maybe a helper method to set the new lists or using an index during the aura:iteration?

  • 2
    List<String> is Apex, but you tagged the question JavaScript. Can you add some of your existing code and show us what you've tried to do this?
    – David Reed
    May 29, 2018 at 16:02

2 Answers 2


Just use a lightning:layout and put your lightning:layoutItems inside with a size of 6. The styles will take care of laying them across two columns.

<lightning:layout multipleRows="true">
  <aura:iteration items="{!v.items}" var="item">
    <lightning:layoutItem size="6">

I hope you are using lightning you can use the array.slice(start, end) to split the initial array of record in your init method.

var sobList = 'get your data here"
var firstHalf;
var secondhalf;
if(sobList.length > 2){
  var midIndex = parseInt(sobList.length/2); 
  firstHalf = sobList.slice(0, midIndex );
  secondhalf = sobList.slice(midIndex +1 , sobList.length -1);

Not the answer you're looking for? Browse other questions tagged or ask your own question.