Eventcalendar V5 - How can I sort correctly?

Eventcalendar V5 - How can I sort correctly?
It would be better if you could turn this off completely and the sorting comes from the database.
This was possible in V4

data {
title: “Platz 1”,
title: “Platz 2”,
title: “Platz 3”,
title: “Platz 10”,
title: “Platz 11”,
…}

– Output —
Platz 1
Platz 10
Platz 11
Platz 2
Platz 3

– Correct –
Platz 1
Platz 2
Platz 3
Platz 10
Platz 11

Platz = Range , or whatever

eventOrder does not work:

eventOrder: function (event1) {
	return event1.title? -1 : 1;
},

Hi Daniel,

Your data should be an array of objects:

data = [{
  title:  “Platz 1”,
  ...
}, {
  title:  “Platz 2”,
  ...
}, {
  title:  “Platz 3”,
  ...
}, {
  title:  “Platz 10”,
  ...
}, {
  title:  “Platz 11”,
  ...
}]

Hi it’s not about that it’s an array of course, it was just a quick example.

It would be better if you could turn this off completely and the sorting comes from the database.

here is the real data:

[
{
	"start": "2022-03-02T09:10:00Z",
	"end": "2022-03-02T19:31:00Z",
	"sgName": "Platz 1",
	"title": "Platz 1",
	"color": "#FF8300",
	"sgEventID": "5122",
},
{
	"start": "2022-03-02T09:10:00Z",
	"end": "2022-03-02T19:31:00Z",
	"sgName": "Platz 10",
	"title": "Platz 10",
	"color": "#FF8300",
	"sgEventID": "5184",
},
{
	"start": "2022-03-02T09:10:00Z",
	"end": "2022-03-02T19:31:00Z",
	"sgName": "Platz 11",
	"title": "Platz 11",
	"color": "#FF8300",
	"sgEventID": "5215",
	
},
{
	"start": "2022-03-02T09:10:00Z",
	"end": "2022-03-02T19:31:00Z",
	"sgName": "Platz 2",
	"sgText": "Platz 2",
	"color": "#FF8300",
	"sgEventID": "5153",
	
},
{
	"start": "2022-03-02T09:10:00Z",
	"end": "2022-03-02T19:31:00Z",
	"sgName": "Platz 3",
	"title": "Platz 3",
	"color": "#FF8300",
	"sgEventID": "5246",
},

]

grafik

Hi Daniel,

Thanks for the clarification. I did indeed misread your message, sorry about that!

So your eventOrder option in this use case should look like the following:

eventOrder: function (event1, event2) {
    return event1.title < event2.title ? -1 : 1;
}

However this won’t be correct in this example either, because of the string comparison (like “Platz 11” < “Platz 2” will be true). I would suggest you to use a custom property (preferably number) for the event order.

In case you don’t use the eventOrder option, the events follow the same order: all-day events at the top followed by everything else sorted by the event start time and events with the same start are ordered alphabetically by title .

Hello,
we had already found and tested this as well. It does not change anything.

The problem are the numbers, in Germany the 1 is in front of the 10. We do not write 01, 02, 03

This does not work:

Platz 10
Platz 11
Platz 1
Platz 2

That works here:

Platz 01
Platz 02
Platz 10
Platz 11

It would be best if ma could disable it and the sorting comes from the JSON database.

Hello Daniel,

That’s correct. This means that the string sort won’t be good in this use case. The order cannot be disabled, the default behaviour is the following: all-day events at the top, followed by everything else sorted by the event start time and events with the same start are ordered alphabetically by title.
The correct usage in this case would be to use a property for ordering, for example:

eventOrder: function (event1, event2) {
    return event1.order < event2.order ? -1 : 1;
},
data: [{
    start: '2022-03-02T09:10:00Z',
    end: '2022-03-02T19:31:00Z',
    title: 'Platz 1',
    color: '#FF8300',
    order: 1

}, {
    start: '2022-03-02T09:10:00Z',
    end: '2022-03-02T19:31:00Z',
    title: 'Platz 10',
    color: '#FF8300',
    order: 10
}, {
    start: '2022-03-02T09:10:00Z',
    end: '2022-03-02T19:31:00Z',
    title: 'Platz 11',
    color: '#FF8300',
    order: 11
}, {
    start: '2022-03-02T09:10:00Z',
    end: '2022-03-02T19:31:00Z',
    title: 'Platz 2',
    color: '#FF8300',
    order: 2
}, {
    start: '2022-03-02T09:10:00Z',
    end: '2022-03-02T19:31:00Z',
    title: 'Platz 3',
    color: '#FF8300',
    order: 3
}]