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

                                                                                                            • The problem with Commerce ownership changing

                                                                                                              Hi, I am changing the ownership of the company and trying to delete the previous user-owner. I changed the owner of the company from user Tatiana to user Eugene. Eugene is the owner of the organization. It's OK. I am now trying to remove the user Tatiana.
                                                                                                            • Secondary Emails

                                                                                                              I am having issues deleting a secondary email address from a couple of our users and need help. When in Directory, manage email addresses, I click the trash icon by the email address and confirm I am trying to delete the email. I click continue and I
                                                                                                            • Kaizen #121 : Customize List Views using Client Script

                                                                                                              Hello everyone! Welcome back to another interesting Kaizen post. In this post, we can discuss how to customize List Views using Client Script. This post will answer the questions Ability to remove public views by the super admin in the Zoho CRM and Is
                                                                                                            • Page Layouts for Standard Modules like CRM

                                                                                                              For standard modules like quotes, invoices, purchase orders, etc, it would be a great feature to be able to create custom page layouts with custom fields in Zoho Books similar to how you can in Zoho CRM. For example, and my current use case, I have a
                                                                                                            • Zoho Books | Product updates | June 2025

                                                                                                              Hello Users, We’ve rolled out new features and enhancements in Zoho Books, from the option to record advances for purchase orders to dynamic lookup fields, all designed to help you stay on top of your finances with ease. Introducing Change Comparators
                                                                                                            • Widget Upload to CRM Fails with “Page Not Found” – Even with Correct Index Path

                                                                                                              I'm building a simple widget to export Contact data to CSV in Zoho CRM, triggered via a custom button. The widget uploads cleanly, appears in the widget list, and is successfully assigned to a Contact detail view via a custom button. But when clicked,
                                                                                                            • Account disabled

                                                                                                              I have an issue I need help with. Whilst trialing ZOHO CRM I created the following: Account1 (-------------) using m__ame@m__rg___s__i__.___.__ and 2 personal emails Account2 (-------------) using a personal email and 2 users _al__1@______________._o_.__
                                                                                                            • How can we manage the tags in ticket

                                                                                                              Allowing agents to use Tags indiscriminately can cause havoc. We could not find tag management where 1. The admin can create Tags beforehand for use by Agents 2. Permission can be allocated which roles/profiles can use existing tags or add new tags 3.
                                                                                                            • Feed Notifications filter?

                                                                                                              I'd like to have filter settings for Feed Notifications just like we have for Personal Email. If someone dumps a bunch of files into a project, we get a notification for every file!
                                                                                                            • Custom fields and filters for Timesheet

                                                                                                              HI Zoho Projects team. IT would be great and useful if we can add custom fields to the Timesheet design And is needed more options for filtering the timesheet dashboard, like "Milestones" and task list asociated to the record. Thank you
                                                                                                            • How do I rename the dropdown that contains a form and a report?

                                                                                                              I want to rename this, but I can't find how
                                                                                                            • Filtering two fields

                                                                                                              Hoping somone can assist, i am trying to create a report to show values from two different fields. e.g I have Field 1 Field 2 In some records, fields 1 and 2 are both "yes"; in other records, only one of the fields has the value "yes". Can we generate
                                                                                                            • Unable to Convert Quote to Invoice – Integration Active but User Not Recognized

                                                                                                              I’m having trouble converting a Quote into an Invoice inside Zoho CRM, even though the Zoho Finance Suite integration is enabled (Invoices, Quotes, Products, and Customers are all checked), and my user is an Admin in both Zoho CRM and Zoho Books, using
                                                                                                            • Owner drawings

                                                                                                              I entered an owner’s drawing transaction in 2023 but it’s still appearing on 2024 books. Is that supposed to happen? Or should Is there an additional step? I prefer for this transaction not to appear.
                                                                                                            • Running Balance in Account Statement.

                                                                                                              Running balance should come by default in the accounting statements but in ZOHO we need to customize every time to get the running balance in accounting statement. I did not understand, when the bank account statement opened from Bank Menu can show the
                                                                                                            • Importing Invoices

                                                                                                              Dear Team I used the enclosed csv file to import some invoices and it worked fine. I had to delete the file and when I am trying to re-upload it, I am getting the error for invoice number and branch "Resource does not exit." I tried a number of different
                                                                                                            • Enhance "Send Cliq Notification" Action in Zoho Desk Workflows (and also add Happiness Rating Support)

                                                                                                              ello Zoho Desk Team, We hope you're doing well. We’d like to submit a feature request regarding the “Send Cliq Notification” action available in Zoho Desk workflows — specifically in workflows triggered by Happiness Ratings, but also relevant to all workflows
                                                                                                            • Treatment of Non-Refundable Income after cancelling an Invoice

                                                                                                              A customer made part payments of 30,000 for an invoice 0f 100,000, and then he is unable to pay up the remaining and has asked for a refund. As per company policy, he can only get 75% of the amount paid, which is 22,500. The remaining 7,500 is non-refundable
                                                                                                            • I need refund

                                                                                                              I have purchased the Zoho Book standard plan; I had the impression that I would get the purchase > Bill feature. After purchasing, I found that billing is not included in the Zoho standard plan. I immediately canceled the subscription. I love the product,
                                                                                                            • Handling identifiers during an import

                                                                                                              Importing your data When importing data into an application, it is crucial to prevent data loss or duplication. These types of errors can hinder the development of a clean and well-organised database, which is essential for effective data management and
                                                                                                            • Creating Deposit Invoices

                                                                                                              Hi, we are a company that does project based work with a request at the begining of each project for a deposit payment. At the moment we are creating invoices for the deposit and an invoice for the completion of the project, however they are completely
                                                                                                            • Marketer’s Space - WhatsApp Pricing Update: What Marketers Need to Know and Do

                                                                                                              Hello Marketers, Welcome back to Marketer’s Space! WhatsApp made changes to their pricing model on July 1, 2025, moving from conversation-based pricing to a per-message pricing model. This week’s post focuses on what these changes mean for your WhatsApp
                                                                                                            • It's time to say goodbye to Zoho Recruit for me.

                                                                                                              Hello, I have been a Zoho Recruit user since 2013. The tool has evolved, with a better UI, new features and so on. The pricing is still a great asset too. BUT, that being said, important features are not coming fast enough. I tried to share my point of
                                                                                                            • change subscription within customer portal

                                                                                                              Would be great for the customer to be able to change their own subscription (or restart existing one) within the customer portal. Also, would like to be able to have early termination fee on subscriptions if canceled early.
                                                                                                            • How to make the add-on optional at the time of subscription?

                                                                                                              The scenario is this, we have a service which has optional add-ons. Like the customer who purchased the subscription may or may not want to get the add-on. In our case if the customer choose the addon we have monetary benefit. In case the user does not
                                                                                                            • Unable to add attachments to knowledge base anymore

                                                                                                              I have been adding articles to knowledge base in Zoho Desk (as part of Zoho One). Today suddenly i found that I am unable to upload and attachments to the articles. I get the following error: "Attachment couldn't be added." I have uploaded the screenshot
                                                                                                            • Advanced factors for multiple scoring rules: Now with Zia scoring automations for all modules

                                                                                                              Greetings all, We're happy to offer improved scoring features by adding extra scoring factors, including Zia Scores, in our multiple scoring rules (MSR) feature. These new factors—which empower existing traditional scoring factors—include criteria for
                                                                                                            • Sortie de Zoho TABLE ??

                                                                                                              Bonjour, Depuis bientôt 2 ans l'application zoho table est sortie en dehors de l'UE ? Depuis un an elle est annoncée en Europe Mais en vrai, c'est pour quand exactement ??
                                                                                                            • Restrict Agents from Editing Shared Custom Views in Zoho Desk

                                                                                                              Hello Zoho Desk Team, We hope you're doing well. We’d like to submit a feature request regarding the custom views functionality in Zoho Desk. 🎯 Background We’re actively using custom views to filter and display tickets for different teams based on specific
                                                                                                            • Introduction Dario Schiraldi Deutsche Bank Executive

                                                                                                              Hello Everyone, Dario Schiraldi serves as a key leader at Deutsche Bank, where he plays a crucial role in shaping the bank's strategic direction and driving operational success. With a solid foundation in finance and leadership, Dario is committed to
                                                                                                            • Is Zoho Shifts included in the Zoho One plan?

                                                                                                              In case the answer is no: there's any plan to make it available via One? Thank you
                                                                                                            • Feature Request: API Access for Managing Deluge Functions (with OAuth & Change Tracking)

                                                                                                              Hi everyone, I wanted to share a thoughtful request that came in from one of our Zoho clients this week. I believe many of us as partners and developers might relate to it. “One quick item to flag: we’d love an official way to manage Deluge functions
                                                                                                            • Moving Subscriptions from one Customer to another

                                                                                                              We frequently need to move subscriptions from one Customer to another Customer in Zoho Billing and the only way we have figured out to do this is to cancel it in the old owner's profile and manually recreate in in the new owner's profile. In doing this,
                                                                                                            • how to add new line in Deluge?

                                                                                                              I want to make string with line separation like this: this is the first line second line third line I have tried to use \n <br> or </br> inside the string but I can't achieve the result like the example above. I want to create a task by using custom function
                                                                                                            • How to pause a subscription/recurring order ?

                                                                                                              Hello, I'm evaluating Zoho Subscriptions for a food co-op where members order a box of produce every week. The software that we're currently using allows members to set up a recurring order. Members can pause the recurring order when they don't want a box for a while and then resume it later. Is it possible to pause/resume a subscription ? Thanks John
                                                                                                            • Hosted Payment Pages - how to update the address in zoho billing

                                                                                                              I"m playing around with the muti-page hosted payment pages which have places for customers to enter their addresses when paying. Why does this not update their address in Zoho Billing after payment? What can I do to make this happen?
                                                                                                            • Tracking training certification expirations

                                                                                                              Hi Zoho Community! I'm looking for some input on the best and most efficient ways to track training expirations in Zoho CRM. I have a very specific workflow that I am looking for - my company offers trainings, and the certification expires every 2 to
                                                                                                            • Kaizen #164 : Client Credentials

                                                                                                              Hello everyone, Welcome back to Kaizen. In this post, we will discuss Client Credentials Flow and when it can be used. What is Client Credentials Flow? According to RFC6749, the official specification for the OAuth 2.0 authorization framework, "The client
                                                                                                            • CRM Email Template Align Left Instead of Center

                                                                                                              Is there a way to make a basic template align to the left instead of center? I know I'm likely forced to the 600px wide with the basic templates but I would REALLY like to set the email to the left instead of center. The basic templates make all the emails
                                                                                                            • Client Script - "Click' Button on Purchase Order - Specify "To Contact" or "To Supplier"

                                                                                                              The send email button is unique on the purchase order in that is has an additional submenu to send email "To Contact" or "To Supplier" It appears that the "click" event in Client script doesn't work correctly, probably because the button click didn't
                                                                                                            • Next Page