Home > Mobile >  How to prevent apify auto-sorting results?
How to prevent apify auto-sorting results?

Time:02-11

Apify recently started to auto-sort results alphabetically. Its really annoying when we are uploading results directly to database.

Original column order given inside the code:

Result1
Result2
.
.
.
Result10
Result11
.
.
.
Result20

After Apify sorts it alphabetically:

Result1
Result10
Result11
.
.
.
Result2
Result20
.
.
.
Result3
Result4
.
.
.
Result9

Is there anyway we can prevent this and retain the original column order?

CodePudding user response:

This has always been like that for tabulated formats. You can add your own sorting if you add the fields parameter to the dataset items URL. Like this

https://api.apify.com/v2/datasets/DATASET_ID/items?clean=true&format=csv&fields=Result1,Result2

As the question was also about the Google Sheets actor, here is a solution for that:

  1. The Google Sheets actor has a column order field
  2. It also has a checkbox to retain the column order of the original sheet
  • Related