How to sort an array variable in ADF

Priya Jha 896 Reputation points
2022-12-07T13:46:52.88+00:00

HI All,

I have an array variable with value [5,8,3,10,1,5] i need to sort values of this array in ascending order like this [1,3,5,5,8,10]

Any way to achieve this via ADF pipeline or dataflows?

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,627 questions
0 comments No comments
{count} votes

Accepted answer
  1. MartinJaffer-MSFT 26,236 Reputation points
    2022-12-08T00:37:03.88+00:00

    Hello @Priya Jha ,
    Thanks for the question and using MS Q&A platform.

    Sorting in a pipeline:
    There is no function to do so at this time. Implementing some sorting algorithm using just pipeline activities is not practical. It would also be expensive. Generally it is best to do the sort outside of Data Factory in that case.

    Sorting in a Dataflow:
    There is a sort function in Dataflow. You could even pass the variable into the dataflow and then operate on that to make new dataflow parameter. However, remember Dataflow is kinda like Copy data activity in that it expects a source and sink. If all you want to do is sort the variable and not move data, it isn't really good use of resources. Also I don't think there is an output for dataflow parameters back into the pipeline. You could write the array to a file, and read that into dataflow and then write it back out once sorted.

    Please do let me if you have any queries.

    Thanks
    Martin


    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
      • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Maatoug wassim 76 Reputation points
    2022-12-07T16:33:39.637+00:00

    Hi, there is a similar answered question (azure-data-factory-sort-values-in-the-array-variab.html)
    Hope it helps.


  2. Nandan Hegde 36,151 Reputation points MVP Volunteer Moderator
    2023-02-25T12:54:23.2733333+00:00

    Hey

    @MartinJaffer-MSFT

    The below blog helps to sort an array via regular expressions :

    https://datasharkx.wordpress.com/2023/02/25/sort-an-array-in-azure-data-factory-synapse-pipeline-via-regular-expressions/

    Can you provide your thoughts on that? Or am I missing out anything


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.