FACE Templating, Jinja, Sorting, Replacing, and dictsort, and natural sort

FACE Templating, Jinja, Sorting, Replacing, and dictsort, and natural sort

Hello,

After some research it looks like Face is a derivative of python's Jinja templating system. 

This is great in the sense that there is actually some rather comprehensive documentation and examples online that can loosely be used to diagnose some issues in your own Face code, but there seem to be enough deviations from Jinja to occasionally make it a little aggravating.

With this in mind, some experimenting has led me to discover two undocumented filters that are quite useful for those using Face.  (I imagine there are probably others):  

The Sort Filter:

The following appears to work as an undocumented "sort" filter:

{% sorted_values = presorted_values | sort(attribute="value") %}


This would appear to corollate to the functionality in Jinja's implementation as described here:


The Replace Filter:

Another is the "replace" filter.  The following code works:

{% sorted_options = sorted_options | replace("}{","},{") %}


This would appear to corollate to the functionality in Jinja's implementation as described here:


The one however that has me a bit stumped is that the documented Face filter "dictsort" does not seem to do anything particularly useful insofar as I can tell - at least for my application.

In my case, I'm trying to sort key:value pairs in Zoho Commerce.  To be more specific, I'm trying sort a list of attribute options by the option name (or value) rather than the option id (which really is only useful in knowing the order in which a set of options was entered, as they're always assigned such that each one is id'd higher than the ones before).

The following is Zoho's documentation for Face's dictsort implementation:

 dictsort

This filter sorts the given values in dictionary, i.e., alphabetical order.

 

Syntax

{{ map_variable | dictsort }}

 

Example

{ % assign map2="{"ant" "black""dog" : "brown" "cat" : "yellow"} %}


{{ map2 | dictsort }}

 

Output

{ant=black, cat="yellow," dog="brown}


The description is a bit vague and doesn't really explain what dictsort does.  Based on the description alone, I might assume that it would be sorting based on the value.  This is not the case.  By looking at the example, it's actually sorting key/value combinations based on the key (the option id in my case) - not the value.

Hoping that the Jinja guide to provide some additional reference, it appears that the jinja dictsort filter should allow you to sort by value: 
{% for item in mydict|dictsort(false, 'value') %}
    sort the dict by value, case insensitive
Unfortunately, I can't seem to get this working in Face in similar fashion.

Given its usefulness - especially for applications related to Zoho Commerce, can Zoho please expand dictsort to more closely mirror the behavior of the Jinja implementation to support sorting based on values instead of keys?

Lastly, I'd like to ask that Zoho might consider implementing one other filter type.  There are several situations in which you might have options, product descriptions, or the like that are sequenced numerically.  For example, if I'm selling lightbulbs, my attributes might be something like: 

50 Watt
75 Watt
100 Watt

If I sorted these using a dictionary sort, they would end up as:

100 Watt
50 Watt
75 Watt

(This same problem is shown when sorting numeric skus in Inventory) 

This of course is because 1 sequentially comes before 5, but the sorting code doesn't recognize that the value 100 is greater than the value of 50.

It would be far better to have a "natural sort" filter.  If python is fact the backend for Face, the code shown here might be useful in doing do:


Thanks,
Bryan


    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • Sticky Posts

                                                            • SEO for your Zoho Sites Website

                                                              Join our live webinar to learn how to use Zoho Sites' SEO tools to boost your website's ranking. Our product specialist will demonstrate everything you need to know about optimizing your web pages to make them search engine friendly. Register here for free: https://www.zoho.com/sites/webinars/
                                                            • Website Accessibility

                                                              I have two sites created in Zoho Sites which are both live. Some questions: 1. Are any of the template themes WCAG 2.1 AA compliant? 2. How do I change the format of a sub-heading in the header section? 3. Is there any way to add focus indication for
                                                            • Unveiling Zoho Sites 2.0 - A new dimension in website building

                                                              Dear Zoho Sites Users, We are thrilled to announce the launch of Zoho Sites 2.0 today! This refresh represents a significant step forward in the capabilities of Zoho Sites and is crucial for creating a lasting and positive impact on our customers' businesses.
                                                            • Visual Editor Webinar

                                                              Join our FREE live webinar to learn how to use the Zoho Sites Visual Editor to easily design your website. Our product specialist will demonstrate how this tool will help you customize your website to suit your requirements.  Register here: https://www.zoho.com/sites/webinars/
                                                            • Zoho Sites Webinar | Integrations

                                                              Join our FREE live webinar to learn how to integrate both Zoho and third-party products with your Zoho Sites website. Our product expert will demonstrate how to use these integrations to grow, manage, and retain the customers you bring in. Learn how to take your business forward and build stunningly robust and efficient websites. Register here: https://www.zoho.com/sites/webinars/


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ








                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Beyond Email: #4 Note taking done right with Notes

                                                                                                              With her favorite links now saved in Bookmarks, Sarah is feeling even more at home in Zoho Mail. As her day fills up with meetings and project discussions, she often finds herself scribbling quick ideas and reminders—only to lose track of them later.
                                                                                                            • When will Sales Order and Invoice Synchronisation with Zoho CRM be Available?

                                                                                                              When will Sales Orders and Invoices, created in Zoho Books or Inventory be made available in Zoho CRM? John Legg Owner: The Debug Store
                                                                                                            • Generate Unique Customer ID for Each for All Contacts

                                                                                                              Generate Unique Customer ID for Each for All Contacts
                                                                                                            • Bookings to Books automation using Flow

                                                                                                              I'm using Zoho Flow to automate a process between Bookings and Books. When someone uses Bookings to schedule time with me I use Flow to automatically add the person as a customer in books, then create a Quote in Books for the type of consultation they
                                                                                                            • Different Canvas for Different account type

                                                                                                              I would like to have a separate canvas for Customers and Resellers that auto-applies when I enter an ACCOUNT. Is this do-able?
                                                                                                            • IMAP sync issues in Zoho CRM

                                                                                                              We are using the Zoho CRM for a while, and we sync (via IMAP) our Google Apps email system. The sync works properly when looking at emails per account, contact or deal, etc. However, it does not function well in the "Messages" and "SalesSigns" features.
                                                                                                            • Reporting tags for custom modules

                                                                                                              Hi, it could be very useful. At field level and at sub table level. Thanks, Eduardo
                                                                                                            • Can't pass Dates and use date filtered Charts in Pages?

                                                                                                              I don't mess with pages very much, but I'm trying to build a dashboard. I have a search element and several charts that need to be filtered. I also have a stateless form for a start/end date picker I am trying to use to filter data for the charts. Here
                                                                                                            • ZOHO FSM Trial - Assets

                                                                                                              Hi I am currently using Zoho CRM and looking at adding FSM. I am trialing FSM at the moment, to potentially move away from my current programme (SimPro) but have a query on the Asset system within FSM It looks like you can only create 1 asset "type";
                                                                                                            • Customize User Invites with Invitation Templates

                                                                                                              Invitation Templates help streamline the invitation process by allowing users to create customized email formats instead of sending a one-size-fits-all email. Different invitation templates can be created for portal users and client users to align with
                                                                                                            • Sending Email with Attachment (PDF, Excel file)

                                                                                                              Hi, I'm new to Zoho CRM and I'm setting up a flow to send an Email with Attachment when user reaching a certain stage of a Deal. In detail, I've created a Blueprint which requires user to attach a PDF file when reaching a certain point of the stage and
                                                                                                            • A letter to the unsung heroes of the internet

                                                                                                              Dear social media marketers, this one’s for you! From the outside, it may look like you're just scrolling through feeds or switching between tabs. But we know better. Team Zoho Social sees the real story. We understand the challenges you face—and we’ve
                                                                                                            • Based on the Assign To time task want to trigger also reminder for the task still move form fresh lead

                                                                                                              If the leads is assigned To 1 am to 10.55 am task want to create 11am Then reminder want to go the person at 4pm If lead status not moved from fresh lead. From next on wards Reminder want to go 11 Am and 4pm Every day still the person moved to fresh lead
                                                                                                            • Emails Not Sending

                                                                                                              This has happened before. I contacted Zoho and it seemed to work, but now my emails are not sending or taking a long time to send and half the time attachments don't attach. It just keeps saying Sending... and I have to keep clicking it to make it send.
                                                                                                            • [Free Webinar] Learning Table Series - AI-Enhanced Logistics Management in Zoho Creator

                                                                                                              Hello Everyone! We’re excited to invite you to another edition of Learning Table Series, where we showcase how Zoho Creator empowers industries with innovative and automated solutions. About Learning Table Series Learning Table Series is a free, 45-60
                                                                                                            • WhatsApp pricing changes: Pay per message starting July 1, 2025

                                                                                                              Starting July 1, 2025, WhatsApp is shifting from conversation-based pricing to per-message billing. That means every business-initiated message you send will count. Not just the first one in a 24-hour window. Pricing updates on the WhatsApp Business Platform
                                                                                                            • Create a button that converts Sales Order into a Custom Module

                                                                                                              I am looking for a way of creating a button on Sales Orders that would automatically create a record in a custom module I have created called Contracts. The custom destination module "Contracts"  has the following fields that I would need to populate [Contracts Name] populate with SalesOrderID [Account Name] populate with related Account Name [Contract Start Date] populate with the date that the record was created Could someone help or point me in the right direction? Thanks
                                                                                                            • Remove all of the junk data that comes with the trial

                                                                                                              How would I go about removing all of the junk data that comes with the trial of zoho crm?
                                                                                                            • Video Interview Feature

                                                                                                              Please add a text option as well while sending invitations to candidates for video interviews, candidates are missing out on the email. They are more convenient in text and it really helps Hope you would understand, thanks
                                                                                                            • Singapore DBS Bank

                                                                                                              Is there any schedule corresponding to DBS of Singapore? 
                                                                                                            • Including Contact and Account Information in Zoho Projects.

                                                                                                              In Zoho Projects I have created a custom layout which already includes a 'Client Information' section. The 'Client Information' section already includes integrated fields (integrated with CRM) for various account and contact details. Here's what I want
                                                                                                            • Unable to Download CRM Contact Data: WorkDrive Integration Issues

                                                                                                              ## Problem Description We need to let users download contact information from CRM as CSV files to their local computers. Since we couldn't implement a direct download option, we're trying to use WorkDrive as a workaround - but we're encountering issues
                                                                                                            • App Spotlight : PagerDuty for Zoho Cliq

                                                                                                              App Spotlight brings you hand-picked apps to enhance the power of your Zoho apps and tools. Visit the Zoho Marketplace to explore all of our apps, integrations, and extensions. In today's fast-paced world, seizing every moment is essential for operational
                                                                                                            • Campaigns going to spam folder, how to build so that it goes to inbox

                                                                                                              Hello, New to campaigns, now have it functioning correctly. In my test group of 10 email addresses 100% of the emails went to spam/junk folder and/or were blocked/captured by spam filters. What is the process to building a message or format that does
                                                                                                            • Integrate QuickBooks with Bigin and streamline your sales and accounting!

                                                                                                              If your business relies on Bigin for customer management and QuickBooks for accounting and invoicing, this new integration is here to make your operations more efficient. By connecting these two platforms, you can now manage your CRM and financial processes
                                                                                                            • When a ticket is merged, the merged ticket's link should redirect to the remaining ticket.

                                                                                                              Zoho Desk deletes merged tickets. Which is not ideal. The issue is if you have a link bookmarked, or even in your inbox from a ticket that was merged, when you visit you receive an error because merging tickets actually deletes the ticket that was merged.
                                                                                                            • Pass data from a Zoho Desk ticket to a Zoho Form as pre-fill data?

                                                                                                              Hello, I'm trying to pre-fill a Zoho form with client data based on the Zoho Desk ticket data that would be associated. Work flow i'm trying to create: 1. Ticket created for a sales order 2. order requires a site survey 3. link inside ticket links to
                                                                                                            • Goods total weight in Sales Orders

                                                                                                              Hello everyone, We want to automatically calculate the total weight in Sales Orders based on the weight data specified in the Items. Could you please suggest the simplest way to achieve this in Zoho Inventory? I would greatly appreciate any advice and
                                                                                                            • Problem with pagination in Zoho Inventory API

                                                                                                              Hello, I'm having an issue with the  Zoho Inventory API when I try to use the pagination. When I send a request to https://inventory.zoho.com/api/v1/items?authtoken=XXXXXXXXXX&organization_id=YYYYYY&page=1&per_page=50, I get back 200 items. And when I send the same request for the second page, https://inventory.zoho.com/api/v1/items?authtoken=XXXXXXXXXX&organization_id=YYYYYY&page=2&per_page=50 I'm getting back the same 200 items I get with the first request.  So I think neither the page parameter
                                                                                                            • Can a user be assigned to an Account based on email domain?

                                                                                                              Hi ZohoDesk, If I have a customer Account already configured is there any way I can use a domain matching rule to assign a new user to the correct account when logging a ticket by email? Many thanks Rich
                                                                                                            • Can't track conversions using GTM

                                                                                                              We had to move the installation of the SalesIQ widget from GTM to directly do it in our wordpress site. The SalesIQ widget was being blocked by Adblockers which caused a lot of our visitors to not be able to see it. This issue was fixed from deleting
                                                                                                            • WhatsApp Message Pricing Changes (Effective July 1, 2025)

                                                                                                              Starting July 1, 2025, Meta will introduce a per-message pricing model on the WhatsApp Business Platform, replacing the current conversation-based billing. This update affects all WhatsApp messages sent through Zoho Marketing Automation. We’ve broken
                                                                                                            • Parent-Child Tickets using API or Deluge

                                                                                                              Hi Everyone, We are looking at the parent-child ticketing features in Zoho Desk. We want to be able to create a parent ticket at customer level and nest child tickets underneath. The issue we are facing is to be able to automate this. I'm checking the
                                                                                                            • Blueprint transitions on locked records

                                                                                                              We use the ability to automatically lock records (quotes, sales orders, etc.) based on criteria, such as stage. For instance, if a quote has been sent to a client, the quote is then locked for further edits. Our ideal quote stage process is: Draft>Sent>Won.
                                                                                                            • CC from mail client to Zoho CRM

                                                                                                              Hi,  Is it possible to have emails sent outside of CRM use a CC that sends them into the CRM and attaches to the record?  Thanks
                                                                                                            • Department e-mail signatures

                                                                                                              Hello everyone, We're just in the process of evaluating various help desk software alternatives and Zoho is looking pretty good to us at the moment. Our set up is a bit strange and I was wondering if this is possible. We have one tech who looks after
                                                                                                            • How can I hide "My Requests" and "Marketplace" icon from the side menu

                                                                                                              Hello everybody, We recently started using the new Zoho CRM for Everyone. How can I hide "My Requests" and "Marketplace" from the side menu? We don't use these features at the moment, and I couldn't find a way to disable or remove them. Best regards,
                                                                                                            • WhatsApp Calling Integration via Zoho Desk

                                                                                                              Dear Zoho Desk Team, I would like to request a feature that allows users to call WhatsApp numbers directly via Zoho Desk. This integration would enable sending and receiving calls to and from WhatsApp numbers over the internet, without the need for traditional
                                                                                                            • Sites Speed and Performance Grades

                                                                                                              I noticed that there are no recent inquiries or complaints about load speed or performance issues with Zoho Sites websites. However, I wanted to understand what Zoho has done to ensure that speed remains optimized, images are compressed and lazy loaded,
                                                                                                            • Include Audio in Zoho Assist Session Recordings

                                                                                                              Hello Zoho Assist Team, We hope you're doing well. We’d like to formally submit a feature request regarding session recordings in Zoho Assist. 🎯 Current Limitation When conducting a Zoho Assist session that includes voice and/or video chatting, the recording
                                                                                                            • Next Page