Code Monkey home page Code Monkey logo

Comments (4)

TomasWell avatar TomasWell commented on July 30, 2024

我是在getFirstLetter方法里面做出的修改,如果有问题还望斧正

    for (NSString* word in wordArr) {
        //如果word是小写 为汉字转的拼音 提取首字符 否则 保留全部
        if (word.length == 0) {

        } else {
            
            NSInteger c_index = [wordArr indexOfObject:word];
            NSString* c;
            if (c_index == 0) {
                c = word;
            } else {
                if (word.length > 1) {
                    c = [word substringToIndex:0];
                } else {
                    c = @"a";
                }
            }

// char c = [word characterAtIndex:0];
// if ((c>96)&&(c<123)) {
// [result appendFormat:@"%c",c];
// }else{
[result appendString:word];
// }
}
}

from bmchinesesort.

TomasWell avatar TomasWell commented on July 30, 2024

我是在getFirstLetter方法里面做出的修改,如果有问题还望斧正

    for (NSString* word in wordArr) {
        //如果word是小写 为汉字转的拼音 提取首字符 否则 保留全部
        if (word.length == 0) {

        } else {
            
            NSInteger c_index = [wordArr indexOfObject:word];
            NSString* c;
            if (c_index == 0) {
                c = word;
            } else {
                if (word.length > 1) {
                    c = [word substringToIndex:0];
                } else {
                    c = @"a";
                }
            }

// char c = [word characterAtIndex:0];
// if ((c>96)&&(c<123)) {
// [result appendFormat:@"%c",c];
// }else{
[result appendString:word];
// }
}
}

from bmchinesesort.

Baymax0 avatar Baymax0 commented on July 30, 2024

我大致了解你的需求了。评论一下。
1、不应该在这个getFirstLetter方法里改,这只是一个单纯返回首字母的方法,改了方法名和实际返回结果不同了。
2、你的写法也没满足你的需求,只能区分拼音不同的,对于“赵”和“招”,你还是会乱
3、如果想区分汉字,应该对汉字做处理,不是对拼音做处理。在排序比较的时候,改进用于比较的key
“首字母” 改进为-> “首字母”+“首汉字的unicode”
4、最后在分组和排序的时候做出响应的改进。

from bmchinesesort.

Baymax0 avatar Baymax0 commented on July 30, 2024

这只是我暂时想到的思路。
另外说一下,抱歉这么久才看到,经常不注意noti。
我已经转swift很久了,所以oc版本应该随缘更新了。
下次更新为swift版本更新缓存机时,会一起改进这个需求的。最后感谢你的提议🙏

from bmchinesesort.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.