PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, July 26, 2022

[FIXED] How to Sort Array in Double List Ansible?

 July 26, 2022     ansible, json     No comments   

Issue

I have a double list like this:

dataset:
    - [dataone, A]
    - [datatwo, C]
    - [dataa, B]
    - [dataa, C]
    - [dataa, B]

I want to sort the first array and have the second array stick with the first one like this:

data:
    - [dataa, B]
    - [dataa, C]
    - [dataa, B]
    - [dataone, A]
    - [datatwo, C]

Any duplicate data needs to still show (the arrangement of second array value doesnt matter)

What should I do?


Solution

this works for me:

- set_fact:
    data: "{{ dataset | sort | list }}"

- name: returned data
  debug:         
    var: data


Answered By - asking
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing