首页 > 其他分享 >mongo聚合字符串类型的数字进行排序

mongo聚合字符串类型的数字进行排序

时间:2023-06-14 20:11:45浏览次数:35  
标签:聚合 mongo Collation Aggregation collation 字符串 排序

  • 设置collation
Collation collation = Collation.of(Locale.CHINESE)
                .numericOrdering(true);
  • 设置聚合选项
Aggregation aggregation = Aggregation.newAggregation(
                Aggregation.match(orOperator),

        ).withOptions(AggregationOptions.builder()
                        .collation(collation)
                .build());

标签:聚合,mongo,Collation,Aggregation,collation,字符串,排序
From: https://www.cnblogs.com/lijiale/p/17481248.html

相关文章

  • 【数据结构和算法面试题】左旋转字符串
    问题分析:本题是常见的旋转字符串的问题,解决的方法是两步旋转的方法:方法:voiddo_reverse(char*p_start,char*p_end){ if(NULL==p_start||NULL==p_end||p_start>p_end)return; chartmp; while(p_start<p_end){ tmp=*p_start; *p_start=*p_end; *p_end......
  • 代码随想录算法训练营第七天| 344.反转字符串 、 541. 反转字符串II、 剑指Offer 05.
     344.反转字符串代码:1voidreverseString(vector<char>&s){23inti=0;4intj=s.size()-1;5while(i<j)6{7charmid=s[i];8s[i]=s[j];9s[j]=mid;1011i++;12......
  • 数据结构和算法——二叉排序树
    一、二叉排序树对于无序的序列“62,58,88,47,73,99,35,51,93,29,37,49,56,36,48,50”,是否存在一种高效的查找方案,使得能够快速判断在序列中是否存在指定的数值?二叉排序树是一种简单,高效的数据结构。二叉排序树,又称为二叉查找树。二叉排序树或者是一棵空树,或者是具有以下性质的二叉树:若其左子树不为......
  • C/C++——排序
    在C/C++中的排序,使用到的函数主要有:sort()qsort()下面详细分析sort()函数和qsort()函数。1、sort()函数sort()是STL中提供的算法,头文件为:#include<algorithm>usingnamespacestd;函数原型如下:template<classRandomAccessIterator>voidsort(RandomAccessIteratorfirst,Ran......
  • PHP基础——字符串的常用操作
    在PHP中使用较多的是字符串的操作,字符串的常用操作主要有如下的几种:字符串的表示字符串的连接去除字符串中的空格和特殊字符字符串的比较分割字符串和合成字符串1、字符串的表示在PHP中,字符串有两种表示的方法:-单引号:”-双引号:”“如:<?php$str_1="Hello\n";......
  • JS排序:插入排序 冒泡排序 选择排序
    1.插入排序 1letarr=[30,5,7,60,22,18,29]2letfn=arr=>{3for(letj=1;j<arr.length;j++){4letcurrent=arr[j]5letpreIdx=j-16while(preIdx>=0&&arr[preIdx]>......
  • boost库之字符串处理
    一、Boost.StringAlgorithmsBoost字符算法库Boost.StringAlgorithms提供了很多字符串操作函数,字符串的类型可以是std::string,std::wstring,或者是任何模板类std::basic_string的实例。这些函数分类别在不同的头文件定义,例如大小写转函数定义在文件boost/algorithm/string/case_c......
  • 快速排序以及 TopN 问题
    快速排序快速排序的划分函数1.firstelement划分2.medianofthreeelement划分快速排序的稳定性TopN问题Referencehttps://baobaobear.github.io/post/20191007-qsort-talk-1/......
  • C# 获取数组排序后的下标
    usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceConsoleApp9{classProgram{staticvoidMain(string[]args){int[]src=newint[]{2,1......
  • 15-1 shell脚本编程进阶字符串切片和高级变量
    一、显示字符的长度[root@centos8~]#str=`echo{a..z}|tr-d''`[root@centos8~]#echostrstr[root@centos8~]#echo$strabcdefghijklmnopqrstuvwxyz[root@centos8~]#name=刘进喜[root@centos8~]#echo${#name}3[root@centos8~]#echo${#str}26二、切片roo......