Contentful logo

Contentful Community

Content order of entries by sorting array

Hi guys,

since there is no option for drag and drop content in content tab (not content model), I have to do it by my own.

So the idea is to sort an array then render it. I made a field in my content model to paste a number. So my query have this structure

query CoursesQuery {
allContentfulCourse(limit: 1000) {
edges {
node {

My idea is to push all numbers from order field to an array, then sort it and then use map to render.
I made a variable with empty array to push there all numbers.

var order = [];

{courses &&
({ node: course }) =>
((order.push(course.order) && (
<Course {…course} />


In console I see a strange array. Null is ok, I didn’t put there numbers.

So when I try to get a first index with order[0] it is undefined.

What am I doing wrong?