CareerCup How would you implement a secondary sorting
来源:互联网 发布:英语培训机构知乎 编辑:程序博客网 时间:2024/05/06 15:08
how would you implement a secondary sorting. Meaning sorting by Category A, and then sub sorting by category B?
--------------------------------------------------------------------------
Three approaches come to mind.
1) Sort on A, then scan the list for runs of elements with the same value for A, then sort each sublist for field B.
2) Sort on A/B simultaneously by using a compare function or key function that uses both fields.
3) Sort the list on B, then stable-sort the list on A.
A nice feature of approach #1 is that you can do it lazily, i.e. only sort the sublists when the second field is queried.
0 0
- CareerCup How would you implement a secondary sorting
- CareerCup Given a dictionary, how would you add spaces in this string
- [每日刷题(2015/6/26)]How would you test a pen?
- How would you test an ATM Machine?
- 10012---How do you think your friends would describe you
- Would you care for a drink?
- Q3.1 Describe how you could use a single array to implement three stacks
- Given an array of characters. How would you reverse it.
- How would you like to integrate with PayPal?
- Would You Like a Shave or a Haircut?
- CC150 3.1 Three in one: describe how you could use a single array to implement 3 stacks.
- hadoop map reduce secondary sorting
- How To: Implement A Server Plug-in
- How to implement a Firewall-Hook Driver
- How do you implement global iPhone Exception Handling?
- You would love this
- CareerCup how will you test if the random number generator is generating actual random numbers
- CareerCup Implement a stack that pops out the most frequently added item
- 在VS2012中调用动态链接库
- c语言学习笔记总结
- 继承关系的类初始化和实例化的顺序
- 第二周作业
- INI文件的读取
- CareerCup How would you implement a secondary sorting
- 基金产品质量线形同虚设
- linux命令
- ThreadLocal
- fimc0硬件格式转换处理usb camera图像数据
- struts1---文件下载
- PHP 冒泡算法示例
- 使用 ROW_NUMBER OVER() 删除相同记录
- grep 常用