Lotusscript 排序字符串数组
我正在尝试对一个字符串数组进行排序,该数组是两个数组列表(添加日期和更改日期)的结果。
combinedAddChangeDates = FullTrim(ArrayAppend(ChangeDate,addDate))
vResult = Evaluate (|@Sort(combinedAddChangeDates)|)
我没有得到任何 vResult 信息。你能帮我吗?
组合AddChangeDates的值如下:
- [1] "22/04/2022-01:00 PM-06:00 PM-已更改"
- [2] "23/04/2022-01:15 PM-06:00 PM-已更改”
- [3]“06/04/2022-08:00 AM-06:00 PM-已添加”
我想根据字符串对它们进行排序日期:
- [1]“06/04/2022-08:00 AM-06:00 PM-已添加”
- [2]“22/04/2022-01:00 PM-06:00 PM-已更改”
- [3]“ 23/04/2022-01:15 PM-06:00 PM-更改”
这在 Lotusscript 中可能吗?太感谢了。
I'm trying to sort a string Array which is a result of two Array lists (Added and Changed Dates).
combinedAddChangeDates = FullTrim(ArrayAppend(ChangeDate,addDate))
vResult = Evaluate (|@Sort(combinedAddChangeDates)|)
I'm getting nothing as vResult. Can you please help me?
The value of combinedAddChangeDates are as follow:
- [1] "22/04/2022-01:00 PM-06:00 PM-Changed"
- [2] "23/04/2022-01:15 PM-06:00 PM-Changed"
- [3] "06/04/2022-08:00 AM-06:00 PM-Added"
I want to sort them according to their string date:
- [1] "06/04/2022-08:00 AM-06:00 PM-Added"
- [2] "22/04/2022-01:00 PM-06:00 PM-Changed"
- [3] "23/04/2022-01:15 PM-06:00 PM-Changed"
Is this possible in Lotusscript? Thank you so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
评估
函数无法识别lotusscript变量,因此当您进行evaliate(| @sort(compinedAddChangedates)|)|)
时,它看到combine> combindedAddchangedates
一个未定义的变量,具有空字符串的默认值。要在
评估
中使用lotusscript变量,您必须将变量转换为字符串并使用定界数将其附加到公式中,以便公式将其视为字面值。此外,在数组的情况下,您必须将数组表示为文字公式列表,其中元素被结肠分开。以下应有效:
vresult = evaluate(| @sort(“ | + join)(compinedAddchangeDates,|”:“ |” |) + |“)|)|)
一种替代方案是实现纯Lotusscript分类功能,因此,您根本不调用
iestuate
。互联网上其他地方可能有例子。该解决方案只是将数组元素作为字符串将其分类,而忽略了您的数据包含日期的事实。当您拥有字符串数据时,基于日期进行排序要复杂得多:您需要从每个元素中提取日期零件,将其转换为实际的日期/时间数据类型(例如使用Lotusscript
cdat
函数),从日期/时间数据中构建和分类一个新数组,然后将排序的日期加入文本部分(“ - 添加”或“变换”),如果您仍然需要这些零件。我尚未提供日期级别的代码,因为这将比我有时间更长。
The
Evaluate
function doesn't recognise LotusScript variables, so when you doEvaluate(|@Sort(combinedAddChangeDates)|)
, it seescombinedAddChangeDates
as an undefined variable with the default value of an empty string.To use a LotusScript variable in
Evaluate
, you have to convert the variable to a string and append it to the formula with delimiters so that the formula sees it as a literal value.Furthermore in the case of an array, you have to represent the array as a literal formula-language list, with elements separated by colons. The following should work:
vResult = Evaluate(|@Sort("| + Join(combinedAddChangeDates, |":"|) + |")|)
An alternative is to implement a pure LotusScript sorting function, so you don't call
Evaluate
at all. There may be examples of this elsewhere on the internet.This solution just sorts the array elements as strings, and ignores the fact that your data contains dates. Sorting based on dates is much more complicated when you have string data: you'd need to extract the date part from each element, convert that to an actual date/time data type (e.g. with the LotusScript
CDat
function), build and sort a new array from the date/time data, then join the sorted dates back to the text parts ("-Added" or "-Changed") if you still need those parts.I haven't provided code for the date-sorting, because that will take longer than I have time for.